ORACLE索引组织表学习(四)

2014-11-24 12:51:14 · 作者: · 浏览: 2
355052

1669600

PCT_USED

96

96

90

ROWS_PER_KEY

1

1

1

BLKS_GETS_PER_ACCESS

3

3

3

PRE_ROWS

0

0

0

PRE_ROWS_LEN

0

0

0

OPT_CMPR_COUNT

0

0

0

OPT_CMPR_PCTSAVE

0

0

0

Shrink 与rebuild又会怎样?

alter index SYS_IOT_TOP_84235 rebuild

ERROR at line 1:

ORA-28650: Primary index on an IOT cannot be rebuilt

我们看到不能通过move 二只能用rebuild index来重新组织数据,从而减少空行,或者空数据块的目的。

组织索引表的ROWID

为了实现对最长访问字段的最快访问,可以使用rowoverflow 存储选项(稍后会祥述 ),将不常被访问的字段从 B-tree 叶块中取出放到一个可选的 (heap-organized)存储区域,从而限制了真正保存在 B-tree 叶块中的数据行 的大小与内容,并可导致在较小的B-tree 中保存更多的数据行。不象heap-organized 配置的情况(表的主键在表和索引中都要保存),索引 组织表没有这种重复存储的情况发生,因为主键字段的值仅保存在 B-tree 索引 中。

由于数据行按照主键的顺序进行保存,通过键压缩特性可以节省出来的大量 空间。

基于逻辑rowid 的主键的使用(与物理rowid 相对应),在索引组织表中的 第二个索引还提供了高可用性。这是因为,rowid 的本身逻辑特性——即使在进行了引起基表数据行移动的表重做操作之后,第二索引也不会变得不可用。与此 同时,通过在逻辑rowid 的物理推测的使用。

select object_id, rowidfrom ORG_INDEX_TABLE where object_id=281

281 *BAEAGSUDwgNS/g

delete from ORG_INDEX_TABLE where object_id=281

insert into ORG_INDEX_TABLE

select * from s_table whereobject_id=281

select object_id, rowid from ORG_INDEX_TABLE whereobject_id=281

281 *BAEAGSUDwgNS/g

看到插入数据后,rowid并没有发生变化。

组织索引表的rowid是逻辑rowid,在堆栈表(正常的heap table)中,rowid没有*, 我们不能根据组织索引表的rowid来推算当前数据所在的数据文件,块号,以及行

运行以下的sql,会引起以下错误信息:

ORA-01410: 无效的ROWID

ORA-06512: 在"SYS.DBMS_ROWID", line 114

ORA-06512: 在line 1

我们已经知道组织索引表本质上就是一个索引,而索引是一个比表复杂的多的数据结构,维护索引产生比维护堆栈表产生更多的redo

truncate tableorg_index_table;

truncate table heap_table;

select a.sid,a.statistic#,a.value

from v$sesstat a, v$statname b

where a.STATISTIC#=b.STATISTIC# and

b.NAME like 'redo size' and

sid=( select sid fromv$mystat where rownum=1)

22304700

insert intoorg_index_table

select * from s_table;

select a.sid,a.statistic#,a.value

from v$sesstat a, v$statname b

where a.STATISTIC#=b.STATISTIC# and

b.NAME like 'redo size' and

sid=( select sid fromv$mystat where rownum=1)

33991716

select 33991716- 22304700 from dual

11687016

insert into heap_table

select * from s_table;

select a.sid,a.statistic#,a.value

from v$sesstat a, v$statname b

where a.STATISTIC#=b.STATISTIC# and

b.NAME like 'redo size' and

sid=( select sid fromv$mystat where rownum=1)

43551060

select 43551060-33991716 fromdual;

9559344

观察到插入组织索引表产生的redo要比插入堆栈表并维护一个主键产生的redo还要多。

我们在察看直径路径加载是否对组织索引表有效

truncate tableorg_index_table;

truncate table heap_table;

select a.sid,a.statistic#,a.value

from v$sesstat a, v$statname b

where a.STATISTIC#=b.STATISTIC# and

b.NAME like 'redo size' and

sid=( select sid fromv$mystat where rownum=1)

43666448

insert /*+append*/ intoorg_index_table

select * from s_table;

select a.sid,a.statistic#,a.value

from v$sesstat a, v$statname b

where a.STATISTIC#=b.STATISTIC# and

b.NAME like 'redo size' and

sid=( select sid fromv$mystat where rownum=1)

55338096

select 55338096- 43666448 from dual

11671648

11687016(没有/*+append*/提示的普通加载)

insert /*+append*/ intoheap_table

select * from s_table;

select a.sid,a.statistic#,a.value

from v$sesstat a, v$statname b

where a.STATISTIC#=b.STATISTIC# and

b.NAME like 'redo size' and

sid=( select sid fromv$mystat where rownum=1)

59308224

select 59308224-55338096 f