SQL优化
1、分页优化
优化前
select * from table where type = 2 and level = 9 order by id asc limit 999, 10;
优化方案
(1)延迟关联
先通过where条件提取出主键,再将该表与原数据表关联,通过主键id提取数据行,而不是通过原来的二级索引提取数据行。
select a.* from table a, (select id from table where type = 2 and level = 9 order by id asc
转载
2021-08-06 16:47:32 ·
78 阅读 ·
0 评论