0%

延迟关联

延迟关联, 通过优先使用索引定位数据范围, 之后再关联完整数据的方式, 加快查询
通常用来优化分页查询

如:

1
select <cols> from profiles where sex = 'M' order rating limit 100000, 10;

随着偏移量的增加, MySQL 需要花费大量的时间来扫描需要丢弃的数据.
通过延迟关联的思想可优化为:

1
2
3
4
5
select <cols> from profiles
inner join (
select <primary key cols> from profiles
where sex = 'M' order by rating limit 100000, 10
) as x using(primary key cols)

1. Resource