[MDEV-20482] MyISAM & Aria very slow when IN predicates containing more than 999 elements reference unindexed column. Created: 2019-09-03 Updated: 2020-08-25 Resolved: 2019-09-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer, Storage Engine - Aria, Storage Engine - MyISAM |
| Affects Version/s: | 10.2.26, 10.3.17, 10.4.7 |
| Fix Version/s: | 10.3.18, 10.4.8 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Juan | Assignee: | Sergei Petrunia |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Environment: |
CentOS 7 |
||
| Issue Links: |
|
||||||||||||||||
| Description |
|
When querying a MyISAM or Aria table on a non-key field using an IN predicate to match values in an un-indexed column, results are fast so long as there are fewer than 1000 elements in the list so the plain select uses the key cache. The 1000th element causes the optimizer to materialize the list and do a join on an unindexed field. The result is that selecting 999 rows from a 5m row table takes 11 seconds while selecting 1000 takes over 24 minutes:
Running a query to select a specific number of rows based on distinct values in the non-key field:
Note that indexing the second column makes the problem go away, since the query plan can then use that second index. This is just to point out that the results are not good when the list exceeds 1000 items and the queried column is not indexed. |
| Comments |
| Comment by Igor Babaev [ 2019-09-04 ] |
|
Juan, |
| Comment by Juan [ 2019-09-04 ] |
|
igor |
| Comment by Igor Babaev [ 2019-09-04 ] |
|
Juan, |
| Comment by Juan [ 2019-09-25 ] |
|
Confirmed fixed in 10.3.18 & 10.4.8 |