first M skip N 的效率太低了。
select * from (
select a.*,rownum RN from (
select * from tt where ................ order by sendtime desc) a
where rownum <=40)
where RN>=31
注意:
1、最内层的SQL尽量设计好索引,避免全表扫描;
2、order by 字段可以创建索引,尽量利用平衡二叉树的顺序性;
另外:
如何测试SQL是否存在随机读写的IO?
做法:
create table tabname as select * from tab2 order by col1;
create index idx1 on tabname(col1);
执行SELECT可以查看是否有磁盘IO:
1、onstat -z;onstat -D
2、onstat -g ppf
3、sqltrace ;onstat -g his 重定向可以查看。