[MDEV-27419] MariaDB doesn't choose DESC index for ORDER BY DESC when MySQL does Created: 2022-01-04 Updated: 2023-11-09 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | N/A |
| Fix Version/s: | 11.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Yuchen Pei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | optimizer-feature | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
MySQL's WL#1074 mentions a limitation:
I suppose it applies to MariaDB as well, even though However, there might still be room for improvement. At least in some cases MySQL is able to pick up the DESC index out of two, while MariaDB isn't:
ANALYZE/statistics collection doesn't change the outcome. Same happens on MariaDB with MyISAM/Aria (ASC index is chosen), but it's not comparable to MySQL because MySQL doesn't support DESC indexes on MyISAM tables. |
| Comments |
| Comment by Sergei Golubchik [ 2022-01-06 ] | ||||||||||
|
We cannot do it in 10.8 properly. A simple heuristics would solve this particular case:
But a universal fix should be cost based, with a new handler method to retrieve the cost of the reverse scan, proper estimation for index_scan_time, etc. psergei, what do you think, shall we have a direction heuristics here until a cost based choice is implemented? |