[MDEV-8076] Performance issue on one request which is 200* slower than Mysql Created: 2015-04-29  Updated: 2018-12-05  Resolved: 2018-04-30

Status: Closed
Project: MariaDB Server
Component/s: Optimizer, Storage Engine - InnoDB, Views
Affects Version/s: 10.0.17, 10.1.19
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Nicolas Trossat Assignee: Alice Sherepa
Resolution: Incomplete Votes: 0
Labels: need_feedback
Environment:

Debian 7 x86_64


Attachments: Text File MDEV-8076-MariaDB-10.1.19.txt     Text File MDEV-8076-MySQL-5.7.16.txt     Zip Archive example.sql.zip     File user.cnf    

 Description   

I had only one request which is 200* slower on MariaDB than Mysql. The others thousands of requests are in the same line or quicker with MariaDB.

I can change the DB server by MariaDB and Mysql and reproduce it each time on Debian 7 on several servers (Virtual or production servers).

I can not send the full database but only the request. It is store on a view. In the example attached, there is no performance issue with 'erp_view_supplyneeds_base', a SELECT take around 0.4 sec and then is well stored in cache, but only with 'erp_view_supplyneeds_global' on wich a SELECT take around 30 sec on MariaDB and is never stored in cache.



 Comments   
Comment by Daniel Black [ 2015-04-29 ]

So the "request" is erp_view_supplyneeds_global?

What queries are you doing on these view (this is usually bad for performance anyway)?

You haven't included your table structures. SHOW INDEXES FROM

{table}

for all table would also help.

Can you include EXPLAIN

{query}

for both views? And on the queries you are using?

The larger query might be exceeding query_cache_limit size and therefore isn't cached.

Honestly these queries are horrible and quite hard to read. use language features.
IF(x > y, x-y, 0) is the same as MAX(x-y,0)
if(x,x,0) is same as COALESCE(x,0)

If you can simplify and include them in a readable presentation that would be good too.

Comment by Nicolas Trossat [ 2015-04-30 ]

I'm full agree with you but I can not change the request, I just host it... And we gone back to Mysql. I report it here because it seems that there is a real bug behind this problem.

The "request" is erp_view_supplyneeds_global. I assume the bug come from the huge amount of SUM(). Just a SELECT * FROM `erp_view_supplyneeds_global` WHERE `product_id` = 1; took 30 sec, instead of 0,5 sec on Mysql.

To help, I will try next week to reproduce the problem on a clean DB and send it to you.

Comment by Daniel Black [ 2015-04-30 ]

A comparative compare of EXPLAIN request_query on mariadb and mysql (which version?) would help.

To help, I will try next week to reproduce the problem on a clean DB and send it to you.

Thank you.

private uploads are there if required: https://mariadb.com/kb/en/meta/ftp/

Comment by Sergei Golubchik [ 2015-06-01 ]

There was no feedback for a month, I'm closing it.
Feel free to add a comment or reopen the issue if you have more information to provide.

Comment by amq [ 2016-12-12 ]

I have the same issue (on CentOS 7).

It occurs both with query cache enabled (stays in "saving in query cache") and disabled (stays in "copying to tmp table").

Both MariaDB 10.1.19 and MySQL 5.7.16 are running with the same config.

Here is a comparative compare of EXPLAIN. I have also uploaded the full db schema to the private ftp.

MDEV-8076-MariaDB-10.1.19.txt MDEV-8076-MySQL-5.7.16.txt

Comment by Daniel Black [ 2016-12-12 ]

Thanks for the explains. I can see the first query is significantly slower on MariaDB. Is there much difference in the wall clock time for the second and third query?

In the mean time MRR settings may help: https://mariadb.com/kb/en/mariadb/multi-range-read-optimization/

These can be set on a session basis for testing.

The supplier of these schemas should be guided to add primary keys indexes to their tables to speed up even the MySQL faster varient.

Comment by amq [ 2016-12-12 ]

Queries:
1: generated by the application, takes >25s
2: the "erp_view_supplyneeds_global" view, takes 25s
3: the "erp_view_supplyneeds_base" view, takes <1s

There is zero wall clock time between all of the queries, I have executed them one by one.

Comment by Alice Sherepa [ 2018-03-26 ]

anybodywise,
do you still have this issue with performance?
If yes, please provide the output of

SHOW global variables\G

Comment by Guillaume Subiron [ 2018-12-05 ]

We encountered the exact same problem, with the exact same view. The best solution is to update BoostMyShop to 2.9.7 or above, because this version removes the problematic views (search for "Maria DB" in http://blogmyshop.com/embedded-erp-2-9-7-is-released-740.html).

But we find a workaround by lowering join_buffer_size. Here are the different query times :

  • With join_buffer_size = 1M and lower : 0.18s after restart, then 0s thanks to cache.
  • With join_buffer_size = 2M: 15s after restart, then 15s again, no cache.
  • With join_buffer_size = 4M: 21s after restart, then 21s again, no cache.
  • With join_buffer_size = 8M or more : 19s after restart, then 19s again, no cache.
Generated at Thu Feb 08 07:24:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.