关于mysql中or条件和索引
时间:2022-03-10 17:00
参考boke:http://blog.csdn.net/hguisu/article/details/7106159
1 .where 语句里面如果带有or条件, myisam表能用到索引, innodb不行。(在mysql5.6下测试如此)
通过检测发现应该把region="melbourne"放在前边。
4. 用in来替换or
这是一条简单易记的规则,但是实际的执行效果还须检验,在oracle8i下,两者的执行路径似乎是相同的.低效:
select…. from location where loc_id = 10 or loc_id = 20 or loc_id = 30
高效
select… from location where loc_in in (10,20,30);
关于mysql中or条件和索引,gxlsystem