[MDEV-18094] Query with order by limit picking index scan over filesort Created: 2018-12-27 Updated: 2019-09-24 Resolved: 2019-09-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.2.28, 10.1.42, 10.3.19, 10.4.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Varun Gupta (Inactive) | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | order-by-optimization | ||
| Issue Links: |
|
||||||||||||
| Description |
|
The dataset used
Now running the query without any limit
Now running the query with limit= NUMBER OF TABLE RECORDS
This looks incorrect, we definitely have a problem with the cost model that changes ref access -> index(or range) by which we can do the ORDERING. With limit = 2x table_records
|
| Comments |
| Comment by Varun Gupta (Inactive) [ 2018-12-27 ] | ||||||||||||||||||||||||||||||
|
Some numbers from the optimizer trace
| ||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-02-14 ] | ||||||||||||||||||||||||||||||
With histograms
WITHOUT EITS
So even with histograms we are picking up index_scan over range_scan! | ||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-02-14 ] | ||||||||||||||||||||||||||||||
|
Looks like an invalid plan:
| ||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-08-26 ] | ||||||||||||||||||||||||||||||
|
Patch | ||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-09-19 ] | ||||||||||||||||||||||||||||||
|
Ok to push. | ||||||||||||||||||||||||||||||
| Comment by Sergei Petrunia [ 2019-09-19 ] | ||||||||||||||||||||||||||||||
|
The patch fixes some of the cases. But does it fix all cases listed in the MDEV? (AFIAU, no?) | ||||||||||||||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-09-21 ] | ||||||||||||||||||||||||||||||
|
In this issue we see for limit = 10000 plan was changed from ref+Filesort to range scan. |