慕容的工作随笔

慕容的工作随笔

记录学习和工作

【原创】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

评论 (0)

还没有评论,来做第一个吧。

发表评论

提交后需管理员审核通过后显示