无论你是InnoD引擎LIMIT分页慢还是MyISAM引擎LIMIT分页慢,大伙SELECT查询分页一般都是这样的【数据总共2万条,需要查询3个字段】:
SELECT `id` , `url` , `content` FROM `product` WHERE 1 ORDER BY `id` LIMIT 10000 , 100
执行速度是:
45.7秒
哈哈,慢的掉渣吧!
MySql LIMIT 分页查询加速利器解决方案:
SELECT `id` , `url` , `content` FROM product INNER JOIN ( SELECT `id` FROM product ORDER BY `id` LIMIT 10000 , 100 ) AS product2 USING ( id )
执行速度是:
0
.03秒
大家以后就不要用传统的分页方法了,要用最新的分页优化加速器解决方案:
SELECT `id` , `url` , `content` FROM product INNER JOIN (SELECT `id` FROM product ORDER BY `id` LIMIT 0 , 100) AS product2 USING ( id )
为什么Mysql分页慢加速器就快?
我只想说4个字:覆盖索引
时间: 2024-11-07 13:39:08