[MDEV-10600] Query Planner Choosing Wrong Index Created: 2016-08-19 Updated: 2016-09-20 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.1.16 |
| Fix Version/s: | 10.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Andrew Arvay | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MariaDB-10.1.16 - Compiled from source |
||
| Attachments: |
|
| Description |
|
I have some issues where the query planner is selecting the wrong index when running queries. The odd part is that it does not match what the EXPLAIN says for the same query in most cases. Example:
Attached a screenshot of the indexes on the table. It should be using the first_post index, but it is not. When I run EXPLAIN on this query, it gives this:
Here is the slow query log:
The engine is clearly using the wrong index - there is no other reason it would be examining over 3 million rows and taking so long to finish. It's worth noting that when I run this query manually and include FORCE INDEX(first_post) it works correctly in 0.001 seconds or similar. Let me know if you need any other info or details! Thanks. |
| Comments |
| Comment by Elena Stepanova [ 2016-08-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please paste SHOW CREATE TABLE for the table, and attach your cnf file(s). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Arvay [ 2016-08-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-08-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm not getting this plan on my artificial data.
I'll pass it over to optimizer experts to take a look at it |