oracle分页的4种方式的优缺点

来源:互联网 发布:c 语言 花指令 编辑:程序博客网 时间:2024/05/29 17:24
1、常规做法——大众写法——速度有衰减,且速度慢
select *          from (select t.*, rownum rn                  from (select * from person order by person_Id) t                 where rownum < 5000000)         where rn > 4999990--30m records --180s


2、简单做法:——速度有衰减,且速度一般
select *  from person where rowid in       (select rid          from (select rid, rownum rn                  from (select rowid rid from person order by person_Id) t                 where rownum < 5000000)         where rn > 4999990)--30m records --11s


3、业务做法——速度基本没有衰减,且速度较快,业务有些绑定
每次再次查询>大于原有最大值然后排序

4、分段:——速度没有衰减,且速度快,业务有些绑定,实现较复杂

启动服务一次或定时对表进行主键分段,记录每段起始终止。分页时,按range key select,便没有衰减
0 0