首页 > 其他 > 详细

优化 or 语句

时间:2017-06-29 09:14:15      阅读:228      评论:0      收藏:0      [点我收藏+]

mysql 演示数据库:http://downloads.mysql.com/docs/sakila-db.zip

 

对于 or  语句,如果要利用索引,则 or 之间的每个条件都必须有索引

 

rental 表索引情况

技术分享

 

 or查询的前后都有索引列---(使用到了索引)

explain select * from rental where staff_id=‘‘ or inventory_id=‘‘\G;

 

技术分享

 

 

复合索引的列  ---(没有使用索引)

 explain select * from rental where rental_date=‘‘ or inventory_id=‘‘\G;

技术分享

 

优化 or 语句

原文:http://www.cnblogs.com/dsitn/p/7092298.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!