数据库复合索引使用条件是什么?什么情况下会失效?
来源:7-11 【实战】 分析SQL的执行计划-[id列]
慕沐4459944
2019-12-03
mysql数据库中设置复合索引(a,b),请说明下列语句是否用到索引,为什么?
1、select * from t where a=0 and b=0;
2、select * from t where a=0 or b=0;
3、select * from t where a>0 or b=0;
4、select * from t where a>0 and b=0;
在线求解答,急等
写回答
1回答
-
sqlercn
2019-12-04
这个在课程中是有讲到的,以下四个查询全都可以使用到a,b列上的复合索引,除第一个查询是可以用到ab两列外,其它的查询都可以利用到ab复合索引中的 a列。
032019-12-04
相似问题