表table存在int类型字段int_a,int_b,一个datetime类型,有三种查询情况:
A:'int_a' = 111 AND 'int_b' = 1111
B: 'int_b' = 111
C: 'int_b'>111 ORDER BY ‘time’ DESC如何考虑建立索引,为什么????
A:'int_a' = 111 AND 'int_b' = 1111
B: 'int_b' = 111
C: 'int_b'>111 ORDER BY ‘time’ DESC如何考虑建立索引,为什么????
create index xxx2 on 表table (int_b,‘time’);
alter table tb add index(b,a) 通过索引定位
B: 'int_b' = 111
有A的索引 B基本不用建立索引
C: 'int_b'>111 ORDER BY ‘time’ DESC
alter table tb add index(b,time) 通过扫描索引扫描 但是不能避免文件排序