使用子查询优化 |
这种方式先定位偏移位置的 id,然后往后查询,这种方式适用于 id 递增的情况。 |
select * from orders_history where type=8 and |
id>=( select id from orders_history where type=8 limit 100000,1) |
limit 100; |
使用 id 限定优化 |
这种方式假设数据表的id是连续递增的,则我们根据查询的页数和查询的记录数可以算出查询的id的范围,可以使用 id between and 来查询: |
select * from orders_history where type=2 |
and id between 1000000 and 1000100 limit 100; |
初级程序员
by: 云代码会员 发表于:2019-10-21 14:40:38 顶(2) | 踩(2) 回复
000
回复评论