3,490
社区成员
发帖
与我相关
我的任务
分享
PARTITION BY RANGE(JGSJ)
(
PARTITION PART_JGJL2010051910 VALUES LESS THAN (to_date('2010-05-19 10','yyyy-mm-dd HH24')) TABLESPACE TS_JGJL_DAT2010051910
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 32M
next 16M
minextents 1
maxextents 255
pctincrease 0
),
…… …… ……
PARTITION PART_JGJLDEFULT VALUES LESS THAN (maxvalue) TABLESPACE TS_JGJL_DAT
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 32M
next 16M
minextents 1
maxextents 255
pctincrease 0
)
);
select /*+order use_nl(t,test) */
object_id,object_name,subobject_name,status
from (select rid from (
select rownum rn, rid from (
select rowid rid from test
where owner='SYS'
and object_type='TABLE'
order by created desc)
where rownum<=500)
where rn>=451)t,
test
where t.rid=test.rid;
先在索引上进行选择,利用索引的排序特性,利用StopKey 终止继续选择(500 以上的记录),
然后直接在索引上分页,再回表。
| Rowid:SYS TABLE 2002-1-1
| Rowid:SYS TABLE 2002-1-2
| Rowid:SYS TABLE 2002-1-3
| Rowid:SYS TABLE 2002-1-4
| 索引 .....
| 顺序
| Rowid:SYS TABLE 2003-1-1 --------------------->
| Rowid:SYS TABLE 2003-1-2 | | 获得50个rowid,再回表(2)
| Rowid:SYS TABLE 2003-1-3 | ----->
| Rowid:SYS TABLE 2003-1-4 |扫描过程(1)
| Rowid:SYS TABLE 2003-1-5 |
| ..... |
| |
| Rowid:SYS TABLE 2004-1-1 |
| Rowid:SYS TABLE 2004-1-2 |
| Rowid:SYS TABLE 2004-1-3 |
| Rowid:SYS TABLE 2004-1-4 --------------------->
......
Nested Loop Join(NL),适用于一个小表(也可以说是小的结果集)关联一个大表,可以认为是在小表上做循环,
然后根据小表的结果返回到大表上去查询数据。
用在LZ的表上,可以用这种方式查询:
select t.*, t.rowid from jgjl t where rownum <= 50
select /*+order use_nl(t,jgjl) */
JGJL_ID,JGJLBH,HPHM,HPLX_ID,HPYS_ID ,FX_ID,LD_ID,CLSD
from (select rid from (
select rownum rn, rid from (
select rowid rid from jgjl
where owner='SYS'
and object_type='TABLE'
order by created desc)
where rownum<=500)
where rn>=451)t,
test
where t.rid=jgjl.rid;