- select * from product limit start, count
- select * from product limit 10, 20 0.016秒
- select * from product limit 100, 20 0.016秒
- select * from product limit 1000, 20 0.047秒
- select * from product limit 10000, 20 0.094秒
- select * from product limit 400000, 20 3.229秒
- select * from product limit 866613, 20 37.44秒
对limit分页问题的性能优化方法
- select id from product limit 866613, 20 0.2秒
- SELECT * FROM product WHERE ID > =(select id from product limit 866613, 1) limit 20
- SELECT * FROM product a JOIN (select id from product limit 866613, 20) b ON a.ID = b.id
- SELECT c1,c2,cn… FROM table LIMIT n,m
推荐分页查询方法
- SELECT c1,c2,cn… FROM table WHERE id>=20000 LIMIT 10;
- SELECT c1,c2,cn… FROM table WHERE id>=(SELECT id FROM table LIMIT 20000,1)LIMIT 10;
- SELECT c1,c2,cn… FROM member ORDER BY last_active LIMIT 50,5
- SELECT c1, c2, cn .. .
- FROM member
- INNER JOIN (SELECT member_id FROM member ORDER BY last_active LIMIT 50, 5)
- USING (member_id)
- SELECT id FROM table LIMIT 20000, 10;
- SELECT c1, c2, cn .. . FROM table WHERE id IN (id1, id2, idn.. .)
打赏
- 支付宝扫一扫
- 微信扫一扫