"오라클 통계정보 이동"의 두 판 사이의 차이
DB CAFE
(새 문서: 통계정보이동하기 스키마/테이블 통계 1.통계정보를 임시로 저장할 테이블 생성 exec dbms_stats.create_stat_table ( '스키마명' ,...) |
|||
140번째 줄: | 140번째 줄: | ||
, 'CYKIM' | , 'CYKIM' | ||
); | ); | ||
+ | |||
+ | [[Category:oracle]] |
2019년 12월 19일 (목) 12:52 판
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
통계정보이동하기
스키마/테이블 통계
1.통계정보를 임시로 저장할 테이블 생성
exec dbms_stats.create_stat_table (
'스키마명' ,'TB_STATS' ,'테이블스페이스명-생략가능' );
1-1.현재 통계정보를 백업받는다.
1) 테이블 백업
exec dbms_stats.export_table_stats(
'CYKIM' -- 스키마명
, 'TB_DICT' -- 테이블명 , NULL -- 파티션명 , 'TB_STATS' -- 통계테이블명 , 'TB_DICT_20161101' -- statid 옵션 식별자(버전) , TRUE -- cascade 인덱스포함하여
, 'CYKIM' -- statown );
dbms_stats.export_table_stats ('table_owner', 'table name', null, 'stat table','stat_id',true,'stat table owner');
2) 스키마 정보
exec dbms_stats.export_schema_stats (
'CYKIM' -- schema name
, 'TB_STATS' -- stat table , 'CYKIM_SCHEMA_20160101' -- stat_id(추후 복구용으로 사용할 ID)
, 'CYKIM' -- stat table owner
); dbms_stats.export_schema_stats ('schema name', 'stat table','stat_id','stat table owner');
2.통계정보수집 1) 테이블 exec dbms_stats.gather_table_stats(
ownname=>'CYKIM' , stattab=>'TB_STATS' , tabname=>'TB_DICT' , method_opt=>'FOR ALL INDEXED COLUMNS SIZE 74' , cascade=>TRUE);
보다자세히 exec DBMS_STATS.GATHER_TABLE_STATS (
'CYKIM'
,'TB_DICT5'
, estimate_percent => 100
, method_opt => 'FOR ALL COLUMNS SIZE 1'
, degree=> 10
, granularity => 'ALL' , cascade => TRUE , no_invalidate => FALSE);
파티션테이블 exec DBMS_STATS.GATHER_TABLE_STATS (
'CYKIM'
, 'TB_DICT5' , partname => 'P201102' -- 파티션명 , estimate_percent => 5 , method_opt => 'FOR ALL COLUMNS SIZE 1' , degree=> 10 , granularity => 'ALL' , cascade => TRUE , no_invalidate => FALSE);
2) 스키마 exec dbms_stats.gather_schema_stats(
ownname => 'CYKIM' , method_opt => 'FOR ALL INDEXED COLUMNS SIZE AUTO' , cascade=>TRUE); 3) 인덱스
exec dbms_stats.gather_index_stats( 'CYKIM' ,'IX_DICT_01');
4) 파티션인덱스
exec dbms_stats.gather_index_stats( ownname => 'CYKIM' , indname => 'IX_DICT_01' , partname => 'P20110222'); 5) 데이터베이스 gather_database_ stats 6) 시스템통계정보 gather_system_stats
7) 보다 상세한 통계정보 generate_stats
3.통계테이블에 EXPORT
1)테이블 정보 EXPORT exec dbms_stats.export_table_stats(
'CYKIM' -- 스키마명
, 'TB_DICT' -- 테이블명 , NULL -- 파티션명 , 'TB_STATS' -- 통계테이블명 , 'TB_DICT_20161101' -- statid 옵션 식별자(버전) , TRUE -- cascade 인덱스포함하여
, 'CYKIM' -- 소유자명
) ; dbms_stats.export_table_stats ('table_owner', 'table name', null, 'stat table','stat_id',true,'stat table owner');
2)스키마 정보 EXPORT exec dbms_stats.export_schema_stats (
'CYKIM' -- schema name
, 'TB_STATS' -- stat table , 'CYKIM_TB_STATS' -- stat_id , 'CYKIM' -- stat table owner ); dbms_stats.export_schema_stats ('schema name', 'stat table','stat_id','stat table owner');
3.EXP/IMP 전환
4.통계정보 넣기 1)테이블 정보 입력 EXEC DBMS_STATS.IMPORT_TABLE_STATS(
'CYKIM' -- 스키마명
, 'TB_DICT' -- 테이블명
, NULL -- 파티션명 , 'TB_STATS' -- 통계테이블 );
dbms_stats.import_table_stats ('table_owner', 'table name', null, 'stat table','stat_id',true,'stat table owner');
2)스키마 정보 입력 exec dbms_stats.import_schema_stats (
'CYKIM' -- schema name
, 'TB_STATS' -- stat table , 'CYKIM_TB_STATS' -- stat_id , 'CYKIM' -- stat table owner );
5.통계정보 복구 exec dbms_stats.import_table_stats (
'CYKIM'
, 'TB_DICT' , NULL , 'TB_STATS' ,' TB_STATS_20161101' -- 통계식별ID , TRUE , 'CYKIM' );