标签:情况 where 限制 mysq 扫描 高性能 范围查询 www 包含
6 覆盖索引
【可参考博文 https://www.cnblogs.com/kerrycode/p/9909093.html】
如果一个索引包含所有需要查询的字段,则称之为“覆盖索引”。
使用覆盖索引,只需要扫描索引,而无需回表:
当发起一个被索引覆盖的查询是,在EXPLAIN中的extra列可以看到 “Using index”的信息。
延迟关联
Explain select * from products where actor = ‘SEAN Carrey‘ and title like ‘%APOLLO%‘;
上述查询不能走上索引:
针对上述情况,可以通过重新设计索引来规避:
修改索引为 actor,title,prod_id
select *
from products
join (
select prod_id from products where actor = ‘SAEN CARREY‘ and title like ‘%APOLLO%‘
) as t1
on (t1.prod_id = products.prod_id)
标签:情况 where 限制 mysq 扫描 高性能 范围查询 www 包含
原文地址:https://www.cnblogs.com/wooluwalker/p/12237300.html