본문 바로가기

Oracle_Script

통계정보 수집할 대상 테이블 조회

/*==========================================================
  통계정보 수집할 대상 테이블 조회 <=  매주 수요일에 수행
    1) Non-partition table
    2) 최근 1주일 동안 analyzed 하지 않은 table
    3) 한번도 analyzed 를 하지 않은 table
    4) insert + delete 된 row가 10% 이상인 table   
    5) Permanent table

==========================================================*/
select t.table_name, t.last_analyzed, t.num_rows, m.mod_rows
from user_tables t
left outer join ( select table_name, (nvl(inserts,0)+nvl(deletes,0)) mod_rows
                    from user_tab_modifications
                    where partition_name is null ) m
on t.table_name = m.table_name
and nvl(t.num_rows,0)/10 <= m.mod_rows   /* insert + delete 된 row가 10% 이상인 table */
and m.mod_rows > 0
where t.tablespace_name is not null   /* Non-partition table */

and DURATION is null    /* Permanent table  */
and ( t.last_analyzed <= sysdate-7 or t.last_analyzed is null )  

    /* 최근 1주일 동안 analyzed 하지 않은 table  or  한번도 analyzed 를 하지 않은 table  */
order by t.num_rows+m.mod_rows nulls first;

/* 작은 table 먼저 수행 */

'Oracle_Script' 카테고리의 다른 글

CRS_STAT 상태 스크립트  (0) 2013.07.04
estd_interconnect_traffic check procedure  (0) 2013.06.27
Client IP 접속자IP 확인  (0) 2012.12.10
Archive Redo Log File Size & Rman Backup File Size  (0) 2012.10.31
Lock_Session_Monitoring  (0) 2012.07.17