EVOLUTION-MANAGER
Edit File: mdev6657.test
--disable_warnings drop table if exists t1,t2,t3; --enable_warnings create table t1(a int); insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t2(a int); insert into t2 select A.a + B.a* 10 + C.a * 100 from t1 A, t1 B, t1 C; CREATE TABLE t3 ( col1 int(10) unsigned NOT NULL DEFAULT '0', col2 mediumint(8) unsigned NOT NULL DEFAULT '0', col3 smallint(5) NOT NULL DEFAULT '1', filler varchar(255) DEFAULT NULL, KEY pk_ersatz(col1,col2,col3), KEY key1 (col1,col2) USING BTREE ) ENGINE=TokuDB DEFAULT CHARSET=latin1 PACK_KEYS=1; insert into t3 select 1300000000+a, 12345, 7890, 'data' from t2; insert into t3 select 1400000000+a, 12345, 7890, 'data' from t2; insert into t3 select 1410799999+a, 12345, 7890, 'data' from t2; insert into t3 select 1410899999+a, 12345, 7890, 'data' from t2; insert into t3 select 1410999999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411099999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411199999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411299999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411399999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411499999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411599999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411699999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411899999+a, 12345, 7890, 'data' from t2; insert into t3 select 1411999999+a, 12345, 7890, 'data' from t2; insert into t3 select 1412099999+a, 12345, 7890, 'data' from t2; insert into t3 select 1412199999+a, 12345, 7890, 'data' from t2; --echo # The following must use range(PRIMARY): --replace_column 9 # explain select col1,col2,col3 from t3 where col1 <= 1410799999 order by col1 desc,col2 desc,col3 desc limit 1; --echo # The same query but the constant is bigger. --echo # The query should use range(PRIMARY), not full index scan: --replace_column 9 # explain select col1,col2,col3 from t3 where col1 <= 1412199999 order by col1 desc, col2 desc, col3 desc limit 1; drop table t1,t2,t3;