[MDEV-10454] Using second tuple nullifies use of an index when using 2-part PK in IN() Created: 2016-07-27 Updated: 2017-04-24 Resolved: 2017-04-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 5.5, 10.0, 10.1 |
| Fix Version/s: | 10.2.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Chris Calender (Inactive) | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | upstream-fixed | ||
| Description |
|
A query of the following form uses an index properly: select * from t where (id1, id2) IN ((1, 1)); However, when you add a second (or more) tuple to the IN() clause, like the below, then the query never uses an index: explain select * from t where (id1, id2) IN ((1, 1),(2,2)); EXPLAIN Outputs:
Test Case:
The first EXPLAIN plan uses an index. The second EXPLAIN plan does not. |
| Comments |
| Comment by Chris Calender (Inactive) [ 2016-07-27 ] | |||||||||||||
|
I thought MRR might help, if enabled, but it does not seem to make a difference:
| |||||||||||||
| Comment by Chris Calender (Inactive) [ 2016-07-27 ] | |||||||||||||
|
Or is it somehow using an index? But "possible_keys" reports NULL. | |||||||||||||
| Comment by Elena Stepanova [ 2016-07-29 ] | |||||||||||||
|
Reproducible on 5.5 - 10.2 and on MySQL 5.6. Not reproducible on MySQL 5.7. | |||||||||||||
| Comment by Sergei Petrunia [ 2016-07-30 ] | |||||||||||||
|
Making range optimizer to handle this is a feature in MySQL 5.7. Originally requested by Domas@FB: http://bugs.mysql.com/bug.php?id=31188 http://dev.mysql.com/worklog/task/?id=7019 | |||||||||||||
| Comment by Oleksandr Byelkin [ 2017-04-03 ] | |||||||||||||
|
see e-mail from 15.03.2017 with the review suggestion. | |||||||||||||
| Comment by Igor Babaev [ 2017-04-04 ] | |||||||||||||
|
A patch to solve this problem was pushed into the 10.2 tree. |