I. 통계정보 비교하기
II. 통계정보 Backup/Recovery
III. Query Invalidation
h3.통계정보전과 후를 비교하는 방법
----------------------------------------------------------------------------------
새로운 통계정보를 생성하는 것은 기존 통계이후 새로운 데이터가 쌓여 있는것 이므로 데이터를 생성한다.
----------------------------------------------------------------------------------
woong:WOONG >
t1 insert into t1
2 select 1,1
3 from dual
4 connect by level <= 100000;
100000 개의 행이 만들어졌습니다.
경 과: 00:00:01.28
woong:WOONG >
t1 commit;
커밋이 완료되었습니다
경 과: 00:00:00.11
woong:WOONG >
t1 exec dbms_stats.gather_table_stats('woong', 't1', method_opt=>'for columns c1 size 254');
PL/SQL 처리가 정상적으로 완료되었습니다.
경 과: 00:00:00.68
woong:WOONG >
t1 select * from table(dbms_stats.diff_table_stats_in_stattab('woong','t1','t1_stat'));
REPORT MAXDIFFPCT
-------------------------------------------------------------------------------- ----------
############################################################################### 1721.05263
STATISTICS DIFFERENCE REPORT FOR:
.................................
TABLE : T1
OWNER : WOONG
SOURCE A : User statistics table T1_STAT <- SOURCE A = T1_STAT 테이블과
: Statid :
: Owner : WOONG
SOURCE B : Current Statistics in dictionary <- SOURCE B = 현재 통계정보 딕셔너리와 비교한다.
PCTTHRESHOLD : 10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TABLE / (SUB)PARTITION STATISTICS DIFFERENCE:
.............................................
OBJECTNAME TYP SRC ROWS BLOCKS ROWLEN SAMPSIZE
...............................................................................
T1 T A 10000 20 7 10000
B 110000 244 6 110000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COLUMN STATISTICS DIFFERENCE:
.............................
COLUMN_NAME SRC NDV DENSITY HIST NULLS LEN MIN MAX SAMPSIZ
...............................................................................
C1 A 10000 .0001 NO 0 4 C102 C302 10000
B 10000 .000009076 YES 0 4 C102 C302 5509
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INDEX / (SUB)PARTITION STATISTICS DIFFERENCE:
.............................................
OBJECTNAME TYP SRC ROWS LEAFBLK DISTKEY LF/KY DB/KY CLF LVL SAMPSIZ
...............................................................................
INDEX: T1_N1
............
T1_N1 I A 10000 19 10000 1 1 18 1 10000
B 110000 346 10000 1 1 172 1 110000
REPORT MAXDIFFPCT
-------------------------------------------------------------------------------- ----------
INDEX: T1_N2
............
T1_N2 I A 10000 19 10000 1 1 18 1 10000
B 110000 346 10000 1 1 172 1 110000
###############################################################################
1 개의 행이 선택되었습니다.
경 과: 00:00:00.03
woong:WOONG >
t1 desc DBA_TAB_STATS_HISTORY
이름 널? 유형
----------------------------------------------------------- -------- ------------------------------------
OWNER VARCHAR2(30)
TABLE_NAME VARCHAR2(30)
PARTITION_NAME VARCHAR2(30)
SUBPARTITION_NAME VARCHAR2(30)
STATS_UPDATE_TIME TIMESTAMP(6) WITH TIME ZONE
woong:WOONG >
t1 select *
2 from (select rownum rn
3 , OWNER
4 , TABLE_NAME
5 , PARTITION_NAME
6 , SUBPARTITION_NAME
7 , STATS_UPDATE_TIME
8 from DBA_TAB_STATS_HISTORY
9 where owner = 'WOONG'
10 order by STATS_UPDATE_TIME desc)
11 where rn = 1;
RN OWNER TABLE_NAME PARTITION_NAME
---------- ------------------------------ ------------------------------ ------------------------------
SUBPARTITION_NAME STATS_UPDATE_TIME
------------------------------ ---------------------------------------------------------------------------
1 WOONG WOONG_T1
09/03/26 17:41:29.625000 +09:00
1 개의 행이 선택되었습니다.
경 과: 00:00:00.03
woong:WOONG >
t1 exec dbms_stats.restore_table_stats('woong','t1', '09/03/26 17:41:29.625000 +09:00');
PL/SQL 처리가 정상적으로 완료되었습니다.
경 과: 00:00:00.15
woong:WOONG >
t1 select * from table(dbms_stats.diff_table_stats_in_stattab('woong','t1','t1_stat'));
REPORT MAXDIFFPCT
-------------------------------------------------------------------------------- ----------
############################################################################### 1721.05263
STATISTICS DIFFERENCE REPORT FOR:
.................................
TABLE : T1
OWNER : WOONG
SOURCE A : User statistics table T1_STAT
: Statid :
: Owner : WOONG
SOURCE B : Current Statistics in dictionary
PCTTHRESHOLD : 10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TABLE / (SUB)PARTITION STATISTICS DIFFERENCE:
.............................................
OBJECTNAME TYP SRC ROWS BLOCKS ROWLEN SAMPSIZE
...............................................................................
T1 T A 10000 20 7 10000
B 110000 244 6 110000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COLUMN STATISTICS DIFFERENCE:
.............................
COLUMN_NAME SRC NDV DENSITY HIST NULLS LEN MIN MAX SAMPSIZ
...............................................................................
C1 A 10000 .0001 NO 0 4 C102 C302 10000
B 10000 .000009076 YES 0 4 C102 C302 5509
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INDEX / (SUB)PARTITION STATISTICS DIFFERENCE:
.............................................
OBJECTNAME TYP SRC ROWS LEAFBLK DISTKEY LF/KY DB/KY CLF LVL SAMPSIZ
...............................................................................
INDEX: T1_N1
............
T1_N1 I A 10000 19 10000 1 1 18 1 10000
B 110000 346 10000 1 1 172 1 110000
REPORT MAXDIFFPCT
-------------------------------------------------------------------------------- ----------
INDEX: T1_N2
............
T1_N2 I A 10000 19 10000 1 1 18 1 10000
B 110000 346 10000 1 1 172 1 110000
###############################################################################
1 개의 행이 선택되었습니다.
경 과: 00:00:00.04
dbms_stats에서 통계정보를 변경하는 모든 procedure는 No_Invalidation 파라미터를 갖는다.