mysql---联合索引是否生效

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xing_____/article/details/78826508
create table test(
id1 int ,
id2 int,
id3 int,
id4 int,
key index_id12(id1,id2)
);

用到索引
explain select * from test where id1 < 10;
用到索引
explain select * from test where id1 < 10 and id2 > 1; 
用到索引
explain select * from test where id2 > 1 and id1 < 2; 
未用到索引
explain select * from test where id2 > 1;
未用到索引
explain select * from test order by id1 desc ;
用到索引
explain select id1 from test order by id1 desc ;
explain select id1,id2 from test order by id1 desc ;
未用到索引
explain select id1,id2,id3 from test order by id1 desc ;

猜你喜欢

转载自blog.csdn.net/xing_____/article/details/78826508