문서유형ㅣ기술정보
분야ㅣ관리/환경설정
적용제품버전ㅣTibero5, Tibero6, Tibero7
문서번호ㅣTADTI225
개요
Partitioning이란?
Table과 Index Data를 Partition 키에 따라 물리적으로 별도의 segment에 저장합니다.
Partitioning의 장점 및 필요성
| 관리적측면 | 파티션 단위 추가, 삭제, 변경, 백업, 복구 |
| 성능적측면 | 파티션 단위 조회 및 DML 수행, I/O 분산 |
방법
Table Partitioning
Range Partition
- 특정 Column Value의 정렬 값을 기준으로 Partitioning
- Historical Data Table에 적합합니다.
- 주로 날짜 컬럼을 기준으로 합니다.
- Partition 순서대로 정의해야 합니다.
- Interval 정의하여 정해진 간격으로 partition 자동 추가가 가능합니다.
Hash Partition
- Partition Key의 Hash값에 의한 Partitioning
- 데이터 분포가 고른 컬럼을 파티션 기준 컬럼으로 선정해야 효과적입니다.
- 2의 제곱수로 Partitioning 하는 것이 좋습니다.
- 경합 분산 및 병렬쿼리 성능향상 효과
- 대용량 거래 Table에 효과적이고 Partition 추가 불가합니다.
List Partition
- 특정 Column의 특정 Value로 Partitioning
- 분포도가 비슷하며, 많은 SQL에서 해당 Column의 조건이 많이 들 어오는 Column을 Partition Key 로 지정하면 효과적 입니다.
- 단일 컬럼만 키로 지정할 수 있습니다.
Composite Partition
- 파티션키에 따라 1차적으로 Data 분배, 서브 파티션 키에 따라 최종적으로 저장할 위치(Segment) 결정
- Range + Hash : 대용량 거래 Table에 좋습니다.
- Range + List : 초대형 이력성 Table을 Range Partitioning하고, 각 파티션을 업무적으로 다시 분할하고자 할 때 주로 이용합니다.
Tibero 지원 Composite Partition 종류
Range Hash List Range O O O Hash O O O List O O O
Partition 관리
Partition 추가
(Range) ALTER TABLE table명 ADD PARTITION partition명 VALUES LESS THAN (value) ; (List) ALTER TABLE table명 ADD PARTITION partition명 VALUES (value) ;Partition 삭제
ALTER TABLE table명 DROP PARTITION partition명;Partition 병합
ALTER TABLE table명 MERGE PARTITIONS partition명1, partition명2 INTO PARTITION partition명2 UPDATE indexes;Partition 분할
ALTER TABLE table명 SPLIT PARTITION partition명2 AT split_key_value INTO (PARTITION partition명1 tablespace tablespace명1, PARTITION partition명2 tablespace tablespace명2) ;Partition 이름 변경
ALTER TABLE table명 RENAME PARTITION old_partition명 TO new_partition명;Partition 테이블스페이스 변경
ALTER TABLE table명 MOVE PARTITION partition명 TABLESPACE tablespace명;Partition Truncate
ALTER TABLE table명 TRUNCATE PARTITION partition명;
관련 Dictionary View
| 뷰 | 정보 |
|---|---|
| USER_TABLES | Table 구조, Partition 유무 |
| USER_PART_TABLES | Partition Type, Default values (Partition된 Table의 정보) |
| USER_TBL_PARTITIONS | Partition Details (각 Partition의 정보) |
| USER_PART_KEY_COLUMNS | Partition Key Details |
Partition Pruning
Pruning이란?
실행 시점에 SQL 조건절을 분석하여 읽지 않아도 되는 세그먼트를 액세스 대상에서 제외하는 기능입니다.
정적(Static) Partition Pruning
- Partition Key 컬럼을 상수 조건으로 조회하는 경우
- 쿼리 최적화 시점에 미리 결정합니다.
- 실행계획의 PS(Partition Start)와 PE(Partition End) 컬럼에 액세스할 Partition 번호가 출력합니다.
동적(Dynamic) Partition Pruning
- Partition Key 컬럼을 Bind 변수로 조회하는 경우
- 실행 시점에 결정합니다.
- 실행계획의 PS, PE 컬럼에 ‘KEY’ 라고 표시됩니다.
Index Partitioning
Global Partition Index
- Table Partition Key와 Index Partition Key가 다른 경우
Local Partition Index
- Table Partition Key와 Index Partition Key가 같은 경우
- 각 Table Partition과 Index Partition이 서로 1:1 대응 관계가 되도록 DB가 자동 관리
- Table Partition에 변화가 생길 시 Index Partition도 동일하게 변화
Partition table에서는 Local Index가 Global Index보다 성능, 가용성 및 관리의 용이성 측면에서 우수합니다.
Index Partition Status
| 작업유형 | 인덱스 | ORACLE | TIBERO |
|---|---|---|---|
| ADD | LOCAL | 상관없음 | 상관없음 |
| GLOBAL | 상관없음 | 상관없음 | |
| DROP | LOCAL | 상관없음 | 상관없음 |
| GLOBAL | 모든 Global Index Unusable | 모든 Global Index Unusable | |
| MERGE | LOCAL | 상관없음 | 상관없음 |
| GLOBAL | 상관없음 | 모든 Global Index Unusable | |
| SPLIT | LOCAL | Split된 Partition Index Unusable | 상관없음 |
| GLOBAL | 모든 Global Index Unusable | 모든 Global Index Unusable | |
| RENAME | LOCAL | 상관없음 | 상관없음 |
| GLOBAL | 상관없음 | 상관없음 | |
| MOVE | LOCAL | Move된 Partition Index Unusable | Move된 Partition Index Unusable |
| GLOBAL | 모든 Global Index Unusable | 모든 Global Index Unusable | |
| TRUNCATE | LOCAL | 상관없음 | 상관없음 |
| GLOBAL | 모든 Global Index Unusable | 모든 Global Index Unusable |
Prefixed
- Index 첫 번째 Column이 Index Partition Key와 같은 경우
- Global Index는 Prefixed Index만 지원합니다.
Non-Prefixed
- Index 첫 번째 Column이 Index Partition Key와 다른 경우
Partitioned Index 생성 시 Prefixed/Non-Prefixed 정의는 하지 않고, DBMS가 체크하여 Dictionary에 기록하고 관리합니다.
관련 Dictionary View
| 뷰 | 정보 |
|---|---|
| USER_INDEXES | Index 구조, Partition 유무 |
| USER_PART_INDEXES | Partition Type, Default values (Partition된 Index의 정보) |
| USER_IDX_PARTITIONS | Partition Details (각 Partition의 정보) |
| USER_PART_KEY_COLUMNS | Partition Key Details |
| USER_IDX_COLUMNS | Index Column 정보 |