Ex) DBA_OBJECTS 에서 (OWNER, OBJECT_TYPE, OBJECT_NAME)에 인덱스를 생성한 경우
(USER1,TABLE,T1) (USER2,TABLE,T2) (USER2,TABLE,T3) (USER2,TABLE,T4) (USER2,TABLE,T5) (USER2,TABLE,T6)
(USER2,TABLE,T7) (USER2,INDEX,I1) (USER2,INDEX,I2) (USER2,INDEX,I3) (USER2,INDEX,I4)
USER1,TABLE T1 T2 T3 T4 T5 T6
T7 USER2,INDEXI1 I2 I3 I4
SQL> create table t1 as select * from dba_objects;
테이블이 생성되었습니다.
SQL> insert /*\+ APPEND \*/ into t1 select * from t1;
49936 개의 행이 만들어졌습니다.
SQL> commit;
커밋이 완료되었습니다.
SQL> insert /*\+ APPEND \*/ into t1 select * from t1;
99872 개의 행이 만들어졌습니다.
SQL> commit;
커밋이 완료되었습니다.
SQL> create table t2 as select * from t1;
테이블이 생성되었습니다.
SQL> create index uncompressed_idx on t1(owner,object_type,object_name);
인덱스가 생성되었습니다.
SQL> create index compressed_idx on t2(owner,object_type,object_name) compress 3;
인덱스가 생성되었습니다.
SQL> analyze index uncompressed_idx validate structure;
인덱스가 분석되었습니다.
SQL> create table index_stat_copy as select * from index_stats;
테이블이 생성되었습니다.
SQL> analyze index compressed_idx validate structure;
인덱스가 분석되었습니다.
SQL> insert into index_stat_copy select * from index_stats;
1 개의 행이 만들어졌습니다.
SQL> commit;
커밋이 완료되었습니다.
SQL> print x
NAME UNCOMPRESSED COMPRESSED DIFF PCT
\---------------\--\--\- --\--\---\--\--\- --\--\-\--\--\- --\--\-\--\--\- --\--\-----\-
BLKS_GETS_PER_ACCESS 5.50477749 5.50477749 0 100
BLOCKS 1408 640 768 45.45
BR_BLKS 9 4 5 44.44
BR_BLK_LEN 8032 8032 0 100 \\
BR_ROWS 1382 618 764 44.72
BR_ROWS_LEN 62454 23745 38709 38.02
BTREE_SPACE 11136288 4981652 6154636 44.73
DEL_LF_ROWS 0 0 0
DEL_LF_ROWS_LEN 0 0 0
DISTINCT_KEYS 49817 49817 0 100
HEIGHT 3 3 0 100
LF_BLKS 1383 619 764 44.76
LF_BLK_LEN 8000 7996 4 99.95
LF_ROWS 199744 199744 0 100
LF_ROWS_LEN 9896776 2197184 7699592 22.2
MOST_REPEATED_KEY 16 16 0 100
OPT_CMPR_COUNT 3 3 0 100
OPT_CMPR_PCTSAVE 55 0 55 0
PCT_USED 90 90 0 100
PRE_ROWS 0 50064 \-50064
PRE_ROWS_LEN 0 2230025 \-2230025
ROWS_PER_KEY 4.00955497 4.00955497 0 100
USED_SPACE 9959230 4450954 5508276 44.69
23 개의 행이 선택되었습니다.
SELECT *
FROM
T1 WHERE OWNER = :B3 AND OBJECT_NAME = :B2 AND OBJECT_TYPE = :B1
call count cpu elapsed disk query current rows
\---\--\-- --\--\----------------------------------------------\-
Parse 1 0.00 0.00 0 0 0 0
Execute 199744 2.26 2.16 0 0 0 0
Fetch 199744 6.12 6.14 90 1408736 0 806336
\---\--\-- --\--\----------------------------------------------\-
*total 399489 8.39 8.31 90 1408736 0 806336*
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
\---\--\-- --\--\----------------------------------------------\-
806336 TABLE ACCESS BY INDEX ROWID T1 (cr=1408736 pr=90 pw=0 time=4550762 us)
806336 INDEX RANGE SCAN UNCOMPRESSED_IDX (cr=604832 pr=0 pw=0 time=2182528 us)(object id 51611)
SELECT *
FROM
T2 WHERE OWNER = :B3 AND OBJECT_NAME = :B2 AND OBJECT_TYPE = :B1
call count cpu elapsed disk query current rows
\---\--\-- --\--\----------------------------------------------\-
Parse 1 0.00 0.00 0 0 0 0
Execute 199744 2.31 2.22 0 0 0 0
Fetch 199744 6.45 6.41 0 1405948 0 806336
\---\--\-- --\--\----------------------------------------------\-
*total 399489 8.76 8.64 0 1405948 0 806336*
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
\---\--\-- --\--\----------------------------------------------\-
806336 TABLE ACCESS BY INDEX ROWID T2 (cr=1405948 pr=0 pw=0 time=4716449 us)
806336 INDEX RANGE SCAN COMPRESSED_IDX (cr=601716 pr=0 pw=0 time=2397303 us)(object id 51612) |
insert into t1 select * from dba_objects 구문을 총 5회 수행
| call count cpu elapsed disk query current rows
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
Parse 7 0.01 0.03 0 0 0 0
Execute 7 10.96 16.59 920 40935 679662 249820
Fetch 0 0.00 0.00 0 0 0 0
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
total 14 *10.98 16.63* 920 40935 679662 249820
insert into t2 select * from dba_objects 구문을 총 5회 수행
| call count cpu elapsed disk query current rows
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
Parse 7 0.01 0.01 0 0 0 0
Execute 7 19.81 28.76 921 35918 682410 249820
Fetch 0 0.00 0.00 0 0 0 0
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
total 14 *19.82 28.78* 921 35918 682410 249820
delete from t1 수행
| call count cpu elapsed disk query current rows
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 27.00 5721 10427 1033820 249820
Fetch 0 0.00 0.00 0 0 0 0
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
total 2 0.00 *27.00* 5721 10427 1033820 249820 |
\- 압축을 사용한 테이블의 삭제 소요 시간
delete from t2 수행
| call count cpu elapsed disk query current rows
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 34.63 2924 6893 1026514 249820
Fetch 0 0.00 0.00 0 0 0 0
\------\- \------ \-------\- \---------\- \---------\- \---------\- \---------- \---------\-
total 2 0.00 *34.63* 2924 6893 1026514 249820
SCOTT,TABLE,EMP SCOTT,TABLE,DEPT SCOTT,TABLE,BONUS
SCOTT,INDEX,EMP_PK SCOTT,INDEX,ENAME_IDX SCOTT,INDEX,DEPT_PK
SCOTT,INDEX,EMP_DEPT SCOTT,INDEX,DNAME_IDX SCOTT,PROCEDURE,P1
SCOTT,PROCEDURE,P2 SCOTT,PROCEDURE,P3 SCOTT,PROCEDURE,P4
SCOTT=<A>,TABLE=<B>,
INDEX=<C>,PROCEDURE=<D>
<A>,<B>,EMP <A>,<B>,DEPT <A>,<B>,BONUS <A>,<C>,EMP_PK
<A>,<C>,ENAME_IDX <A>,<C>,DEPT_PK <A>,<C>,EMP_DEPT <A>,<C>,DNAME_IDX
<A>,<D>,P1 <A>,<D>,P2 <A>,<D>,P3 <A>,<D>,P4
SQL> create table uncompressed pctfree 0
2 as select * from dba_objects order by owner,object_type,object_name;
테이블이 생성되었습니다.
SQL> analyze table uncompressed compute statistics;
테이블이 분석되었습니다.
SQL> create table compressed pctfree 0 compress
2 as select * from dba_objects order by owner,object_type,object_name;
테이블이 생성되었습니다.
SQL> analyze table compressed compute statistics;
테이블이 분석되었습니다.
SQL> create table compressed_random pctfree 0 compress
2 as select * from dba_objects order by dbms_random.random;
테이블이 생성되었습니다.
SQL> analyze table compressed_random compute statistics;
테이블이 분석되었습니다.
SQL> select cblks comp_blks,crblks compr_blks, uncblks uncomp_blks,
2 round(cblks/uncblks*100,2) pct1,
3 round(crblks/uncblks*100,2) pct2
4 from (
5 select max(decode(table_name,'COMPRESSED',blocks,null)) cblks,
6 max(decode(table_name,'COMPRESSED_RANDOM',blocks,null)) crblks,
7 max(decode(table_name,'UNCOMPRESSED',blocks,null)) uncblks
8 from user_tables
9 where table_name in ( 'COMPRESSED', 'COMPRESSED_RANDOM', 'UNCOMPRESSED' )
10 )
11 /
COMP_BLKS COMPR_BLKS UNCOMP_BLKS PCT1 PCT2
\-----\--\--\- --\--\-\--\--\- --\--\--\--\--\- --\--\-\--\--\- --\--\-----\-
345 451 617 55.92 73.1
SQL> ed
file afiedt.buf(이)가 기록되었습니다
1 create table compressed_timestamp pctfree 0 compress
2\* as select * from dba_objects order by timestamp
SQL> /
테이블이 생성되었습니다.
SQL> analyze table compressed_timestamp compute statistics;
테이블이 분석되었습니다.
SQL> select blocks from user_tables where table_name='COMPRESSED_TIMESTAMP';
BLOCKS
\---------\-
*209*