use test; --disable_query_log source bug34928_small.dump; --enable_query_log #let $select_fields= a,b,d,c; #let $select_fields= hex(a),hex(b),hex(d),hex(c); #let $limit_nr= 10; #select distinct hex(a),hex(b),hex(d),hex(c) from test order by a,b,d,c limit 10; #eval explain select distinct $select_fields from test order by $select_fields limit $limit_nr; #eval select distinct $select_fields from test order by $select_fields limit $limit_nr; #--exit explain select distinct a,b,d,c from test order by a,b,d,c limit 10; explain select distinct a,b,d,c from test order by a,b,d,c limit 9; select distinct a,b,d,c from test order by a,b,d,c limit 10; select distinct a,b,d,c from test order by a,b,d,c limit 9; CREATE TABLE t1 ( `a` char(4) NOT NULL DEFAULT '', `b` char(18) NOT NULL DEFAULT '', `c` char(1) NOT NULL DEFAULT '', `d` char(2) NOT NULL DEFAULT '', `e` char(4) NOT NULL DEFAULT '', PRIMARY KEY (`a`,`b`,`c`,`d`,`e`), KEY `COMP2` (`a`,`b`,`d`,`c`) ); insert into t1 select * from test limit 53; show create table t1; select distinct a,b,d,c from t1 order by a,b,d,c limit 10; select distinct a,b,d,c from t1 order by a,b,d,c limit 9; select count(*) from test; select count(*) from t1; DROP TABLE test; DROP TABLE t1;