表结构 xxxx(id, ,content,url,status) id为主键,自动递增
普通分页
select * from xxxx where status = 1 limit 1000,100;这样查询在数据量比较小,同时查询前面的数据的时候是很快的.但是如果表的数量持续增大(这里的测试数据有589530条数据),同时需要查询后面分页的数据,如:
select * from xxxx where status = 1 limit 235500,500;执行上面这条语句,就会很慢. 这里测试结果是 8-9s的样子
优化分页
利用id主键,如下:
select * from xxxx where id >=(select id from xxxx where status=1 limit 235500,1) and status = 1 limit 500;上面这条语句的执行结果是 0.24s
效率一下提升40多倍
继续阅读与本文标签相同的文章
上一篇 :
Ubuntu笔记--添加启动脚本
下一篇 :
Mysql笔记--常用命令
-
彻底卸载MYSQL
2026-06-02栏目: 教程
-
SublimeText 3中文输入
2026-06-02栏目: 教程
-
Phantomjs截图乱码
2026-06-02栏目: 教程
-
RMI执行过程分析
2026-06-02栏目: 教程
-
Ubuntu下Wireshark普通权限不足之解决方案
2026-06-02栏目: 教程
