[MDEV-16214] Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY Created: 2018-05-18 Updated: 2019-05-20 Resolved: 2019-05-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0, 10.1, 10.2, 10.3 |
| Fix Version/s: | 10.3.16, 10.4.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Varun Gupta (Inactive) | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Create the test dataset
Then run the query
The query plan is
Now I run the query
As I see none of the elements for key1 is NULL, so the second query should behave exactly as the first one but it doesn't. |
| Comments |
| Comment by Varun Gupta (Inactive) [ 2018-05-18 ] |
|
After discussing this with psergey , So here when we add the t2.key1 IS NOT NULL condition and make a ref access on Apart from ref(const) , we consider estimate from quick keys if ref is using the same key |
| Comment by Varun Gupta (Inactive) [ 2018-06-11 ] |
|
Patch |
| Comment by Sergei Petrunia [ 2019-05-16 ] |
|
Taking over as we discussed the issue in connection with another bug ( The patch is ok to push, but please replace the loop with a single comparison like tab->ref.const_ref_part_map == make_prev_keypart_map(tab->ref.key_parts). |
| Comment by Sergei Petrunia [ 2019-05-16 ] |
|
Ok to push |
| Comment by Varun Gupta (Inactive) [ 2019-05-17 ] |
|
Patch |
| Comment by Sergei Petrunia [ 2019-05-19 ] |
| Comment by Sergei Petrunia [ 2019-05-19 ] |
|
Ok to push after the review input is addressed. |