[Oracle TABLE SIZE 및 INDEX SIZE(크기) 계산]
1. TABLE SIZE 계산 공식(ORACLE BLOCK SIZE : 2K 로 가정)
------------------------------------------------------
$ sqlplus scott/tiger
SQL> SELECT GREATEST(4, ceil(ROW_COUNT /
((round(((1958 - (initrans * 23)) *
((100 - PCTFREE) /100)) / ADJ_ROW_SIZE)))) * BLOCK_SIZE)
TableSize_Kbytes
FROM dual;
*. 한 개의 BLOCK에 Available 한 Bytes - 1958
*. 각 initrans 는 23 Bytes
*. PCT_FREE : Table 의 pctfree 값(default 10)
*. ADJ_ROW_SIZE : 각 row 의 평균 SIZE 추정치
*. ROW_COUNT : table 의 row 의 갯수
*. BLOCK_SIZE : 1 block의 크기 (단위: K)
예) table 이름이 EMP 일 경우
ROW_COUNT : select count(*) from emp;
ADJ_ROW_SIZE :
analyze table emp compute statistics;
(또는 건수가 매우 많을 때에는 compute 대신 estimate 사용)
select avg_row_len
from user_tables
where table_name='EMP';
2. INDEX SIZE 계산 공식
-----------------------
SQL> SELECT GREATEST(4, (1.01) * ((ROW_COUNT /
((floor(((2048 - 113 - (initrans * 23)) *
(1 - (PCTFREE/100))) /
((10 + uniqueness) + number_col_index +
(total_col_length)))))) * DB_BLOCK_SIZE))
IndexSize_Kbytes
FROM dual;
*. 한 개의 block에 available 한 bytes ( 1935 or 2048 - 113 )
*. 각 initrans 는 23 Bytes
*. ROW_COUNT : table 의 row 의 갯수
*. PCTFREE : Index 의 pctfree 값(default 10)
*. number_col_index : Index 에서 column 의 수
*. total_col_length : Index 의 길이 추정치
*. uniqueness : 만일 unique index 이면 1, non-unique index 이면 0.
*. DB_BLOCK_SIZE : 1 block의 크기 (단위: K)
'(DB) Oracle > Table' 카테고리의 다른 글
Oracle - Table Foreign Key Stop/Start (0) | 2017.01.21 |
---|---|
Oracle - Table foreign key (0) | 2017.01.21 |
Oracle - Tablespace (0) | 2017.01.21 |
Oracle - Table (0) | 2017.01.21 |