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 id1 from test order by id1 desc ;
explain select id1,id2 from test order by id1 desc ;

 

未用到索引

explain select * from test order by id1 desc ;

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

 

组合索引与order by的相互使用影响不是很熟悉,求大神留言解答

相关文章:

  • 2022-01-18
  • 2022-12-23
  • 2021-03-31
  • 2021-05-06
  • 2021-08-19
  • 2022-01-23
猜你喜欢
  • 2021-09-29
  • 2021-08-11
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2021-07-29
相关资源
相似解决方案