I have 8 millions of records in table and this query is just too slow. It's for sitemap (that we need to index it all). In this example I choose 1000 items from position 6 millions.
SELECT source, identifier
FROM mh_download
WHERE deleted =0
LIMIT 6000000 , 1000
Run Code Online (Sandbox Code Playgroud)
33 seconds
Table is MyISAM and column deleted has index. MySQL version 5.5.41.
我发现重复 为什么 MYSQL 更高的 LIMIT 偏移会减慢查询速度?
所以最好的解决方案是
1)Hold the last id of a set of data(30) (e.g. lastId = 530)
2)Add the condition "WHERE id > lastId limit 0,30"
Run Code Online (Sandbox Code Playgroud)
感谢大家的耐心等待
| 归档时间: |
|
| 查看次数: |
647 次 |
| 最近记录: |