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

 

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

 

rental 表索引情况

优化 or 语句

 

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

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

 

优化 or 语句

 

 

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

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

优化 or 语句

 

相关文章:

  • 2021-11-20
  • 2021-10-24
  • 2021-08-18
  • 2022-01-12
  • 2022-01-01
猜你喜欢
  • 2021-06-22
  • 2022-12-23
  • 2021-12-24
  • 2021-05-31
  • 2022-12-23
相关资源
相似解决方案