[MDEV-10452] Poor performance after upgrade from 10.1.14 to 10.1.16 Created: 2016-07-27 Updated: 2016-07-28 Resolved: 2016-07-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1.16 |
| Fix Version/s: | 10.1.16 |
| Type: | Bug | Priority: | Major |
| Reporter: | Josep Sanz | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | 10.1.16, performance, query | ||
| Environment: |
This problem was detected in a CentOS 7 and Fedora 23 environment |
||
| Attachments: |
|
| Description |
|
After the upgrade from the 10.1.14 to 10.1.16, I have detected that some queries need a lot of time to be executed. When I have downgraded to the 10.1.14, I have checked that the problem has dissapeared. I have executed the mysql_upgrade after each upgrade. I attach some files that I expect that help you to understand the problem and fix it.
|
| Comments |
| Comment by Elena Stepanova [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Looking at the attached files... The difference between query plans is only the first two tables. The query has "ORDER BY a.id desc LIMIT 0,50" 10.1.14:
the table a has type=index, but rows=4, i.e. the query plan relies on the fact that it is producing rows in LIMIT order and so will be able to terminate early. In 10.1.16:
The first table is 'e'. "Using temporary" and "Using filesort" are used to produce the required ordering (this means execution can't finish early after producing #LIMIT rows). | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
looking at schema.sql one can see the tables are using MyISAM, so apparently any fixes in 10.1.16 that relate to "Extended Keys" are not at fault. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Looking at the tables in the problematic join:
table 'd' is not present in either good or bad query plan, it seems it was "a left join e" is converted into an inner join. I see it in EXPLAIN EXTENDED (tried both 10.1.14 and 10.1.16) when trying to reproduce with dummy data:
and also one can see it manually. The big select has e.id_usuario id_usuario | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm testing with a dummy dataset that I have generated ( id_usuarios_c - 10 rows, tbl_usuarios - 1 row, all other tables: 1K rows each). And the interesting part is that I'm getting the same difference in EXPLAINs:
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Trying to debug where it comes from
== 10.1.16 ==
Apparently, JOIN_TAB::dependent is different. In 10.1.14 e->dependent= {a}, in 10.1.16 e->dependent=0. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
I would say that the value in 10.1.16 is the correct one. e->dependent=0 makes more sense when the query is a INNER JOIN e. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Ok, the change in behavior that I'm observing was caused by the fix for
(now, looking if there is anything we could do here) | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Actually, the query plan reported for 10.1.16 should be able to avoid doing "Using filesort" with improved ORDER BY optimizations. sanz, would it be possible for you to
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Josep Sanz [ 2016-07-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Sergei. With the optimizer_switch option works as expected as you can see in the attached files. I explain-10.1.16-v2.log Thanks by your help. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
sanz, you're welcome. It should be safe to just run with 'orderby_uses_equalities=on' while on MariaDB 10.1. In the next MariaDB release (10.2), it will be ON by default. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-07-28 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Closing as there is a workaround ( |