zoukankan      html  css  js  c++  java
  • mysql何时使用组合索引

    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的相互使用影响不是很熟悉,求大神留言解答

  • 相关阅读:
    Liunx cal
    Liunx read
    IOS
    IOS
    ARPSpoofing教程(四)
    ARPSpoofing教程(三)
    ARPSpoofing教程(二)
    数据结构与算法分析
    hdu 2034
    hdu 2042
  • 原文地址:https://www.cnblogs.com/lzghyh/p/13229170.html
Copyright © 2011-2022 走看看