[MDEV-18066] DELETE/UPDATE and ORDER BY ... LIMIT - the choice is not cost-based Created: 2018-12-23 Updated: 2019-08-05 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1, 10.2, 10.3 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | order-by-optimization | ||
| Issue Links: |
|
||||||||
| Description |
|
Here, it will use range + sorting regardless of whether it is possible to use some other index that would match the LIMIT. For comparison:
|
| Comments |
| Comment by Sergei Petrunia [ 2018-12-23 ] | ||||||||||||||
|
This was intended this way by the code in get_index_for_order.
| ||||||||||||||
| Comment by Sergei Petrunia [ 2018-12-23 ] | ||||||||||||||
|
The worse part is that quick select is constructed regardless of whether it is cheap (= and whether its condition is selective): SQL_SELECT::test_quick_select() is invoked with the limit parameter having the value from the LIMIT in the query. The effect of this is:
which means a quick select is constructed if at all possible. For example:
A plan to use range access to read 900 rows (out of 1000 in the table).
|