Bug #67432 | Serious performance degradation for the query with ORDER BY ... LIMIT n | ||
---|---|---|---|
Submitted: | 31 Oct 2012 5:46 | Modified: | 11 Dec 2012 1:49 |
Reporter: | Igor Babaev | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S5 (Performance) |
Version: | 5.6.7 | OS: | Any |
Assigned to: | Jørgen Løland | CPU Architecture: | Any |
[31 Oct 2012 5:46]
Igor Babaev
[5 Nov 2012 8:34]
Jørgen Løland
Hi Igor, Thank you for the bug report. Reproduced using the following simplified test script: create table t1 ( pk int primary key auto_increment, i int, j int, k int, index (i), index (j), index (k) ) engine=myisam; insert into t1 (i,j,k) values (1,1,1); let $1=12; set @d=1; while ($1) { eval insert into t1 (i,j,k) select i+@d, j+@d, k+@d from t1; eval set @d=@d*2; dec $1; } explain select * from t1 where i<1000 and (j<100 or k < 100) order by i limit 5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge i,j,k j,k 5,5 NULL 196 Using sort_union(j,k); Using where; Using filesort
[11 Dec 2012 1:49]
Paul DuBois
Noted in 5.6.10, 5.7.1 changelogs. The optimizer sometimes chose a nonoptimimal range scan strategy when a query included a LIMIT clause.