[MDEV-6796] Unable to skip filesort when using implicit extended key Created: 2014-09-26 Updated: 2014-10-06 Resolved: 2014-10-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.13, 10.1.0 |
| Fix Version/s: | 10.1.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | extended-keys, optimizer, order-by-optimization | ||
| Description |
|
The optimizer is able to skip filesort when PK columns are explicitly defined in the secondary index, but not able to do so when they are in the index extension. Test dataset:
Note that the first query uses "Using filesort" while the second one doesn't. |
| Comments |
| Comment by Sergei Petrunia [ 2014-09-26 ] | ||||||||||
| Comment by Sergei Petrunia [ 2014-09-26 ] | ||||||||||
|
The problem is here in test_if_order_by_key() function:
Here, (table->key_info[idx].ext_key_part_map & 1) == 0. This condition is false, and I don't see any reason why we should require that it is true. (Investigated what ext_key_part_map is. See here: http://lists.askmonty.org/pipermail/commits/2014-September/006655.html) MySQL 5.6 has different code, but it's still incorrect. Their code doesn't take into account that secondary index may explicitly include columns from the primary index. | ||||||||||
| Comment by Sergei Petrunia [ 2014-09-26 ] | ||||||||||
|
Fix pushed to the 10.1-based tree with ORDER BY optimization fixes: https://github.com/MariaDB/server/tree/bb-10.1-orderby-fixes elenst, I need a testing pass for this fix. It is ok to test together with other fixes in 10.1-orderby-fixes. |