Solo  当前访客:3 开始使用

mysql分页查询优化


1、普通分页查询

查询40w条时

当达到百万条时,需要花费十几s的查询时间

2、优化分页

利用表的覆盖索引来加速分页查询

我们都知道,利用了索引查询的语句中如果只包含了那个索引列(覆盖索引),那么这种情况会查询很快。

因为利用索引查找有优化算法,且数据就在查询索引上面,不用再去找相关的数据地址了,这样节省了很多时间。

select id from product limit 800000, 20 0.2秒

 --利用了主键索引

分页查询

1)id>=

SELECT * FROM product WHERE ID > =(select id from product limit 800000, 1) limit 20

2)join

SELECT a.* FROM product a JOIN (select id from product limit 800000, 20) b ON a.ID = b.id


标题:mysql分页查询优化
作者:hugh0524
地址:https://blog.uproject.cn/articles/2016/06/26/1466915425552.html

, , , , 0 0