[MDEV-32646] Query planner doesn't use the full index for a query filtering on indexed columns Created: 2023-11-01 Updated: 2023-11-01 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.3.39, 11.1.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Ivan Krylov | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian Buster |
||
| Description |
|
Originally discussed at MariaDB discuss. For the following table:
and the following query:
I get a query plan that doesn't fully use the spid_flag_wl index. On 11.1.2, it's not using an index at all:
and on 10.3.39, it's using a prefix of the index:
It's possible to make the query optimiser use the index with FORCE INDEX(spid_flag_wl), after which the query speeds up from 90 seconds to 11 seconds to select 3 million rows out of 40 million. No amount of ANALYZE TABLE lets the optimiser use the full index automatically. I can share the 2-gigabyte dump (the table is constructed from publicly-available ExoMol files) or perform additional experiments myself if needed. |