前言

Limit分页通用方案
select * from yundou_v3.bill_info limit 100,20;
select * from yundou_v3.bill_info limit 400000,20;
select * from yundou_v3.bill_info limit 600000,20;
select * from yundou_v3.bill_info limit 800000,20;
select * from yundou_v3.bill_info limit 1000000,20;

图片


量级数据分页方案

SELECT * FROM yundou_v3.bill_info WHERE id>= (
    select id as id from yundou_v3.bill_info order by id asc limit 100,1
) limit 20;

SELECT * FROM yundou_v3.bill_info WHERE id>= (
    select id as id from yundou_v3.bill_info order by id asc limit 400000,1
) limit 20;

SELECT * FROM yundou_v3.bill_info WHERE id>= (
    select id as id from yundou_v3.bill_info order by id asc limit 600000,1
) limit 20;

SELECT * FROM yundou_v3.bill_info WHERE id>= (
    select id as id from yundou_v3.bill_info order by id asc limit 800000,1
) limit 20;

SELECT * FROM yundou_v3.bill_info WHERE id>= (
    select id as id from yundou_v3.bill_info order by id asc limit 1000000,1
) limit 20;

mysql量级数据表的分页优化方案

实现步骤:

1.获取start_id

select id as start_id from yundou_v3.bill_info order by id asc limit  n*page_size ,1

2.获取start_id后面的n条数据

SELECT * FROM yundou_v3.bill_info WHERE id>= “start_id” limit 20;