행위

Shrink 세그먼트

DB CAFE

Dbcafe (토론 | 기여)님의 2020년 2월 29일 (토) 17:08 판 (낭비되고 있는 영역 조각모음하기)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
thumb_up 추천메뉴 바로가기


스토리지 용량 관리를 위해 Shrink 기능을 수행한다. 사용법은 아래의 순서대로 진행 된다.

1 현재 임계치(Threshold) 값 확인[편집]

select warning_value, critical_value from dba_thresholds
 where metrics_name='Tablespace Space Usage'
   and object_name is null;

2 임계치 경고 메시지 확인[편집]

select reason, message_level from dba_outstanding_alerts
 where object_name='TBSALERT';

3 현재 사용하고 있는 블럭수와 HWM를 확인[편집]

select count(distinct dbms_rowid.rowid_block_number(rowid)) blocks from emp;
-> 실제 사용하고 있는 블럭수를 출력한다.
select blocks, extents from user_segments where segment_name='EMP';
-> HWM(High Water Mark, 사용된 블럭과 사용하지 않은 블럭의 경계선)이 할당된 블럭수 출력

4 낭비되고 있는 영역 조각모음하기[편집]

alter table emp ENABLE ROW MOVEMENT;
    -> row id가 바뀔수 있기에 행이주를 허용한다.
alter table emp shrink space compact;
    -> 실제 사용 하는 블럭만 정리한다. HWM는 앞당겨 지지 않는다.
alter table emnp shrink space;
    -> 블럭과 HWM까지 정리한다.

이후 3번 작업을 다시하여 Shrink 작업 전후를 비교해 본다..