[MDEV-23487] query analizer chooses the wrong index where it should obviously choose another Created: 2020-08-14 Updated: 2020-09-30 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.5.5 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sean Garrett | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
any environment, tested both on Linux and windows |
||
| Description |
|
I have two tables, this is a financial application so performance is paramount.
now look at this query:
please note the where clause: this is an exact match for "fai" index, but it keeps choosing the "a_id" index and I think I found out why, it seems like because I am selecting "h.a_id", no matter what, it chooses the a_id index because this index has "a_id" column in it even though the where clause very obviously says to use 'fai' index. now to prove this point if I choose a different colunm in the query (please note the where clause is exactly the same, only selecting a different column h.u):
it chooses the correct index (fai). so I'm not sure why, maybe it is how it should be but to me it seems like pretty obvious. my database has millions of records so this could be an issue in a large database, currently I'm forcing the query to use fai index (use index (fai)). thanks for your attention |