[MDEV-7885] EXPLAIN shows wrong info for ORDER BY query Created: 2015-03-30 Updated: 2016-04-17 Resolved: 2016-04-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0, 10.1 |
| Fix Version/s: | 10.2.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | order-by-optimization | ||
| Description |
|
EXPLAIN output doesn't match query execution for a query.
This looks odd - why does the optimizer use index key1 when we have explicitly specified *ignore index for order by (key1)* ? Let's run the SELECT itself:
It shows that the query did use filesort. |
| Comments |
| Comment by Sergei Petrunia [ 2015-03-30 ] | ||||||||||||||||||||||||||||
|
The reason for this is that the choice whether to use an index is made by two different pieces of code (one for EXPLAIN, another one for SELECT). EXPLAIN uses this code in JOIN::exec_inner():
SELECT uses this in create_sort_index:
The create_sort_index() call is the second one made from JOIN::exec_inner. | ||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2015-04-16 ] | ||||||||||||||||||||||||||||
|
Checked on MySQL 5.7: they correctly return "Using filesort" | ||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2016-04-17 ] | ||||||||||||||||||||||||||||
|
This was fixed as part of |