ORACLE索引组织表学习(一)

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

索引组织表

索引组织表的存储结构是按照主键的B-tree 结构搭建的。不象普通的表(堆 积表——数据的存储是无序进行的),索引组织表中的数据是按照主键的 B-tree 结构排序后保存的。包括保存索引组织表行的主键字段值在内,B-tree 中的每一 个索引项还保存了非键字段的值。

组织索引表实际上就是索引的表化

为什么要引进组织索引表

create table org_index_table

( object_id int primary key,

oname varchar2(30),

owner varchar2(30),

status varchar2(30))

organization index;

create table heap_table

( object_id int primary key,

oname varchar2(30),

owner varchar2(30),

status varchar2(30)

)

alter table org_index_table nologging;

alter table heap_table nologging;

create table s_table as

select object_id, object_name, owner,status

from all_objects

insert into heap_table select * from s_table

call count cpu elapsed disk query current rows

------- ------ -------- -------------------- ---------- ---------- ----------

Parse 1 0.01 0.00 0 1 0 0

Execute 1 0.48 0.62 90 2301 11134 70231

Fetch 0 0.00 0.00 0 0 0 0

------- ------ -------- -------------------- ---------- ---------- ----------

total 2 0.50 0.63 90 2302 11134 70231

Misses in library cache during parse: 1

Optimizer mode: ALL_ROWS

Parsing user id: 114

Rows Row Source Operation

------- ---------------------------------------------------

0 LOAD TABLE CONVENTIONAL (cr=2575 pr=90 pw=90 time=0 us)

70231 TABLE ACCESS FULL S_TABLE (cr=450 pr=88pw=88 time=1380 us cost=128 size=4239300 card=81525)

Elapsed times include waiting on following events:

Event waited on Times Max. Wait Total Waited

---------------------------------------- Waited ---------- ------------

db file scattered read 16 0.08 0.14

db file sequential read 8 0.01 0.02

log file sync 1 0.00 0.00

SQL*Net message to client 1 0.00 0.00

SQL*Net message from client 1 0.00 0.00

Insert into org_index_table select* from s_table

call count cpu elapsed disk query current rows

------- ------ -------- -------------------- ---------- ---------- ----------

Parse 1 0.00 0.00 0 1 0 0

Execute 1 0.39 0.57 0 2389 10939 70231

Fetch 0 0.00 0.00 0 0 0 0

------- ------ -------- -------------------- ---------- ---------- ----------

total 2 0.39 0.57 0 2390 10939 70231

Rows Row Source Operation

------- ---------------------------------------------------

0 LOAD TABLE CONVENTIONAL (cr=2535 pr=0 pw=0 time=0 us)

70231 TABLE ACCESS FULL S_TABLE (cr=450 pr=0 pw=0time=1079 us cost=128 size=4239300 card=81525)

Elapsed times include waiting on following events:

Event waited on Times Max. Wait Total Waited

---------------------------------------- Waited ---------- --------