PostgreSQL两种分页方法查询时间比较
2015-09-24 13:43
1021 查看
数据库中存了3000W条操作日志,两种分页查询测试时间
第一种
SELECT * FROM log_operation WHERE i_id>1000 limit 100;
Time: 0.016s
第二种
SELECT * FROM log_operation limit 100 OFFSET 1000;
Time: 0.003s
第一种
SELECT * FROM log_operation WHERE i_id>10000 limit 100;
Time: 0.004s
第二种
SELECT * FROM log_operation limit 100 OFFSET 10000;
Time: 0.508s
第一种:
SELECT * FROM log_operation WHERE i_id>100000 limit 100;
Time: 0.003s
第二种:
SELECT * FROM log_operation limit 100 OFFSET 100000;
Time: 2.377s
SELECT * FROM log_operation WHERE c_act='登录' limit 100 OFFSET 100000;
Time: 3.649s
第一种:
SELECT * FROM log_operation WHERE i_id>1000000 limit 100;
Time: 0.004s
第二种:
SELECT * FROM log_operation limit 100 OFFSET 1000000;
Time: 14.403s
第一种:
SELECT * FROM log_operation WHERE i_id>10000000 limit 100;
Time: 0.057s
第二种:
失去等待出来结果的耐心!!!
建议使用第二种分页方法
第一种
SELECT * FROM log_operation WHERE i_id>1000 limit 100;
Time: 0.016s
第二种
SELECT * FROM log_operation limit 100 OFFSET 1000;
Time: 0.003s
第一种
SELECT * FROM log_operation WHERE i_id>10000 limit 100;
Time: 0.004s
第二种
SELECT * FROM log_operation limit 100 OFFSET 10000;
Time: 0.508s
第一种:
SELECT * FROM log_operation WHERE i_id>100000 limit 100;
Time: 0.003s
第二种:
SELECT * FROM log_operation limit 100 OFFSET 100000;
Time: 2.377s
SELECT * FROM log_operation WHERE c_act='登录' limit 100 OFFSET 100000;
Time: 3.649s
第一种:
SELECT * FROM log_operation WHERE i_id>1000000 limit 100;
Time: 0.004s
第二种:
SELECT * FROM log_operation limit 100 OFFSET 1000000;
Time: 14.403s
第一种:
SELECT * FROM log_operation WHERE i_id>10000000 limit 100;
Time: 0.057s
第二种:
失去等待出来结果的耐心!!!
建议使用第二种分页方法
相关文章推荐
- MySQL用户管理
- Oracle 中count函数用法
- Oracle EBS Model Function Technical
- sql的一些操作,游标分页,事务
- redis2.8默认配置
- oracle sql 日期yyyy-MM-dd字符串和timstamp类型相互转换
- C#操作SQL Server数据库
- mysql中DATE_FORMAT()和str_to_date() 、to_days
- sql之left join、right join、inner join的区别
- MySql常用操作指令
- oracle 函数
- [TopCoder SRM420 Div1 500pt RedIsGood]【数学期望】【动态规划】
- MySql出现ERROR 1130
- sqlserver 视图和sql语句的效率对比
- sql 学习笔记 档
- mysql的“Got error 28 from storage engine”错误
- 使用Jedis连接集群Redis(支持Redis复杂操作)
- Navicat for MySQL(mysql图形化管理工具)是什么?
- centos下为php开oracle扩展
- MySQL下Limit使用及性能分析