SQL> CREATE TABLE IOTAB
(COL_PK NUMBER PRIMARY KEY,
COL2 VARCHAR2(500),
COL3 NUMBER,
COL4 VARCHAR2(1000))
ORGANIZATION INDEX TABLESPACE USERS
PCTTHRESHOLD 10 INCLUDING COL2
OVERFLOW TABLESPACE USERS;
conn scott/loveora
create table iot
(username varchar2(30), document_name varchar2(30),
other_data char(100), constraint iot_pk
primary key (username, document_name))
organization index
TABLESPACE TOOLS
INCLUDING "DOCUMENT_NAME" OVERFLOW TABLESPACE USERS;
create table heaps
(username varchar2(30), document_name varchar2(30),
other_data char(100), constraint heap_pk
primary key (username, document_name));
begin
for i in 1 .. 100
loop
for x in (select username from all_users)
loop
insert into heaps (username, document_name, other_data)
values(x.username,x.username || '_' || i,'x');
insert into iot (username, document_name, other_data)
values(x.username,x.username || '_' || i,'x');
end loop;
end loop;
commit;
end;
/
alter session set tracefile_identifier='IOT_HEAP';
set timing on
set time on
alter session set sql_trace=true;
set autotrace on
declare
type array is table of varchar2(100);
l_array1 array;
l_array2 array;
l_array3 array;
begin
for i in 1 .. 10
loop
for x in (select username from all_users)
loop
for y in (select * from heaps single_row where username = x.username)
loop
null;
end loop;
for y in (select * from iot single_row where username = x.username)
loop
null;
end loop;
select * bulk collect
into l_array1,l_array2,l_array3
from heaps bulk_collect
where username = x.username;
select * bulk collect
into l_array1,l_array2,l_array3
from iot bulk_collect
where username = x.username;
end loop;
end loop;
end;
/
22:29:54 SQL> /
PL/SQL procedure successfully completed.
query1 】
select * from heaps single_rows;
USERNAME DOCUMENT_NAME OTHER_DATA
-------------- -------------- --------------
LOGCOPSDB LOGCOPSDB_90 x
ANONYMOUS ANONYMOUS_90 x
2900 rows selected.
Elapsed: 00:00:05.26
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 1 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 195 0.02 0.03 0 245 0 2900
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 197 0.02 0.04 0 246 0 2900
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 54 (SCOTT)
Rows Row Source Operation
------- ---------------------------------------------------
2900 TABLE ACCESS FULL HEAPS (cr=245 pr=0 pw=0 time=182821 us)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
2900 TABLE ACCESS (FULL) OF 'HEAPS' (TABLE)
query2 】
select * from iot single_rows;
USERNAME DOCUMENT_NAME OTHER_DATA
-------------- -------------- --------------
SCOTT SCOTT_67 x
SCOTT SCOTT_68 x
2900 rows selected.
Elapsed: 00:00:05.87
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.01 0 2 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 195 0.05 0.07 0 290 0 2900
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 197 0.06 0.08 0 292 0 2900
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 54 (SCOTT)
Rows Row Source Operation
------- ---------------------------------------------------
2900 INDEX FAST FULL SCAN IOT_PK (cr=290 pr=0 pw=0 time=424398 us)(object id 53144)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
2900 INDEX (FAST FULL SCAN) OF 'IOT_PK' (INDEX (UNIQUE))
query3 】
select * from heaps bulk_collect;
USERNAME DOCUMENT_NAME OTHER_DATA
-------------- -------------- --------------
LOGCOPSDB LOGCOPSDB_90 x
ANONYMOUS ANONYMOUS_90 x
2900 rows selected.
Elapsed: 00:00:05.92
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.01 0 2 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 195 0.04 0.05 0 245 0 2900
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 197 0.05 0.06 0 247 0 2900
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 54 (SCOTT)
Rows Row Source Operation
------- ---------------------------------------------------
2900 TABLE ACCESS FULL HEAPS (cr=245 pr=0 pw=0 time=188558 us)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
2900 TABLE ACCESS (FULL) OF 'HEAPS' (TABLE)
query4 】
select * from iot bulk_collect;
USERNAME DOCUMENT_NAME OTHER_DATA
-------------- -------------- --------------
SCOTT SCOTT_39 x
SCOTT SCOTT_4 x
2900 rows selected.
Elapsed: 00:00:05.96
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 2 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 195 0.04 0.05 0 290 0 2900
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 197 0.04 0.06 0 292 0 2900
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 54 (SCOTT)
Rows Row Source Operation
------- ---------------------------------------------------
2900 INDEX FAST FULL SCAN IOT_PK (cr=290 pr=0 pw=0 time=174079 us)(object id 53144)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT MODE: ALL_ROWS
2900 INDEX (FAST FULL SCAN) OF 'IOT_PK' (INDEX (UNIQUE))
alter table iot add OVERFLOW TABLESPACE users INCLUDING "DOCUMENT_NAME";
conn sys/loveora as sysdba
@$ORACLE_HOME/rdbms/admin/dbmsiotc.sql
@$ORACLE_HOME/rdbms/admin/PRVTIOTV.PLB
EXECUTE DBMS_IOT.BUILD_CHAIN_ROWS_TABLE('SCOTT','IOT');
conn scott/loveora
ANALYZE TABLE IOT LIST CHAINED ROWS INTO IOT_CHAINED_ROWS;
conn scott/loveora
select object_name, object_id
from dba_objects
where object_name='IOT' and owner='SCOTT';
object_name object_id
============ ==========
IOT 53143
select segment_name, segment_type, bytes, blocks
from dba_segments
where segment_name like '%53143%' OR segment_name = 'IOT_PK';
segment_name segment_type bytes blocks
================= ============= ======== =======
SYS_IOT_OVER_53143 TABLE 65536 8
IOT_PK INDEX 524288 64
select table_name, iot_type, iot_name, tablespace_name
from dba_tables
where table_name = 'IOT'
or (iot_name = 'TEST_CHECK' and iot_type = 'IOT_OVERFLOW');
table_name iot_type iot_name tablespace_name
================== ============== ============ =================
SYS_IOT_OVER_53143 IOT_OVERFLOW IOT USERS
IOT IOT
SELECT index_name, index_type, tablespace_name, table_name
FROM dba_indexes
where table_name = 'IOT';
index_name index_type tablespace_name table_name
================== ============= ================ =============
IOT_PK IOT - TOP TOOLS IOT_PK
1. A = IOT Index (IOT_PK)
2. B = OVERFLOW segment(SYS_IOT_OVER_53143)
3. T = IOT에 의해 사용된 total Physical Storage Space
4. IOT에 의해 사용된 총 space(T) = A + B
☞ T = 8 + 64 = 72 Oracle Blocks.