【原创】MySQL limit优化

百万级别表的limit优化:

select * from code order by id limit 1000000,10
执行时间:0.622

select a.* from code a inner join (select id from code order by id limit 1000000,10) b USING(id)

执行时间:0.235s

 

select * from code where id>=(select id from code order by id limit 1000000,1) limit 10;

执行时间:0.235s

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注