Word-break: break-all; border: 0px; outline: 0px; vertical-align: baseline; background: rgb(255, 255, 255); overflow: hIDden; color: rgb(51, 51, 51); font-family: "Microsoft Yahei", -apple-system, BlinkMACSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei UI", "Source Han Sans CN", sans-serif; white-space: normal;">为大家介绍MySql大数据分页查询性能优化的方法,希望大家学习后能有所提升。
- 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.. .)
打赏
支付宝扫一扫
微信扫一扫