Sunteți pe pagina 1din 4

col "Space (M)" for 999,999.

99 SELECT occupant_name, round( space_usage_kbytes/1024) "Space (M)", schema_name, move_procedure FROM v$sysaux_occupants ORDER BY 1 / retrieve the oldest and latest AWR snapshot, SELECT snap_id, begin_interval_time, end_interval_time FROM SYS.WRM$_SNAPSHOT WHERE snap_id = ( SELECT MIN (snap_id) FROM SYS.WRM$_ SNAPSHOT) UNION SELECT snap_id, begin_interval_time, end_interval_time FROM SYS.WRM$_S NAPSHOT WHERE snap_id = ( SELECT MAX (snap_id) FROM SYS.WRM$_SNAPSHOT) / select dbms_stats.get_stats_history_retention from dual; Whenever statistics in the dictionary are modified, old versions of statistics a re saved automatically for future restoring. The old statistics are purged autom atically at regular intervals based on the statistics history retention setting and the time of recent statistics gathering performed in the system. Retention i s configurable using the ALTER_STATS_HISTORY_RETENTION procedure. The default va lue is 31 days. That is normally not too big an issue but in our Peoplesoft environments we run a lot of gather_stats jobs and if the retention period is not managed then the S YSAUX tablespaces can grow very large. In one of our systems the SYSAUX tablespa ce was 37Gb with over 32Gb consisting of the stats tables and assoc iated indexe s. This blog entry will provide the scripts to diagnose and correct excessive ta blespace growth due to retained statistics view sourceprint?01 set linesize 120 02 set pagesize 100 03 04 COLUMN "Item" FORMAT A25 05 COLUMN "Space Used (GB)" FORMAT 999.99 06 COLUMN "Schema" FORMAT A25 07 COLUMN "Move Procedure" FORMAT A40 08 09 SELECT occupant_name "Item", 10 11 12 space_usage_kbytes/1048576 "Space Used (GB)", schema_name "Schema", move_procedure "Move Procedure"

13 FROM v$sysaux_occupants 14 ORDER BY 1

15 / Item Space Used (GB) re ------------------------- -----------------------------------------AO .00 _AWMETA EM .08 nce.move_em_tblspc EM_MONITORING_USER .00 EXPRESSION_FILTER .00 JOB_SCHEDULER .00 LOGMNR .01 MNR_D.SET_TABLESPACE LOGSTDBY .00 STDBY.SET_TABLESPACE ODM .00 ORDIM .00 ORDIM/PLUGINS .00 ORDIM/SQLMM .00 SDO .00 DO SM/ADVISOR .02 SM/AWR .15 SM/OPTSTAT 11.44 SM/OTHER .02 STATSPACK .00 STREAMS .00 TEXT .00 SYS TSM .00 ULTRASEARCH .00 ULTRASEARCH_DEMO_USER .00 WM .00 _proc XDB .00 .MOVEXDB_TABLESPACE XSAMD .00 e_OLAP_Catalog XSOQHIST .00 apiMoveProcHow long old stats are kept Schema Move Procedu

------------------------- -----------SYS SYSMAN DBSNMP EXFSYS SYS SYSTEM SYSTEM DMSYS ORDSYS ORDPLUGINS SI_INFORMTN_SCHEMA MDSYS SYS SYS SYS SYS PERFSTAT SYS CTXSYS TSMSYS WKSYS WK_TEST WMSYS XDB OLAPSYS SYS DBMS_AW.MOVE emd_maintena

SYS.DBMS_LOG SYS.DBMS_LOG MOVE_ODM

MDSYS.MOVE_S

DRI_MOVE_CTX MOVE_WK MOVE_WK DBMS_WM.move XDB.DBMS_XDB DBMS_AMD.Mov DBMS_XSOQ.Ol

view sourceprint?1 select dbms_stats.get_stats_history_retention from dual; Set retention of old stats to 10 days view sourceprint?1 exec dbms_stats.alter_stats_history_retention(10); Purge stats older than 10 days (best to do this in stages if there is a lot of d ata (sysdate-30,sydate-25 etc) view sourceprint?1 exec DBMS_STATS.PURGE_STATS(SYSDATE-10); Show available stats that have not been purged view sourceprint?1 select dbms_stats.get_stats_history_availability from dual; Show how big the tables are and rebuild after stats have been purged

view sourceprint?1 col Mb form 9,999,999 2 col SEGMENT_NAME form a40 3 col SEGMENT_TYPE form a6 4 set lines 120 5 select sum(bytes/1024/1024) Mb, segment_name,segment_type from dba_segments 6 where tablespace_name = 'SYSAUX' 7 and segment_name like 'WRI$_OPTSTAT%' 8 and segment_type='TABLE' 9 group by segment_name,segment_type order by 1 asc MB SEGMENT_NAME SEGMEN ---------- ---------------------------------------- -----0 WRI$_OPTSTAT_OPR TABLE 0 WRI$_OPTSTAT_AUX_HISTORY TABLE 88 WRI$_OPTSTAT_TAB_HISTORY TABLE 126 WRI$_OPTSTAT_IND_HISTORY TABLE 158 WRI$_OPTSTAT_HISTGRM_HISTORY TABLE 4,482 WRI$_OPTSTAT_HISTHEAD_HISTORY TABLEShow how big the indexe s are ready for a rebuild after stats have been purged view sourceprint?01 col Mb form 9,999,999 02 col SEGMENT_NAME form a40 03 col SEGMENT_TYPE form a6 04 set lines 120 05 select sum(bytes/1024/1024) Mb, segment_name,segment_type from dba_segments 06 where tablespace_name = 'SYSAUX' 07 and segment_name like '%OPT%' 08 and segment_type='INDEX' 09 group by segment_name,segment_type order by 1 asc 10 / MB ---------0 0 0 88 105 105 195 213 214 SEGMENT_NAME ---------------------------------------WRH$_OPTIMIZER_ENV_PK I_WRI$_OPTSTAT_OPR_STIME I_WRI$_OPTSTAT_AUX_ST I_WRI$_OPTSTAT_TAB_ST I_WRI$_OPTSTAT_IND_ST I_WRI$_OPTSTAT_H_ST I_WRI$_OPTSTAT_TAB_OBJ#_ST I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST I_WRI$_OPTSTAT_IND_OBJ#_ST SEGMEN -----INDEX INDEX INDEX INDEX INDEX INDEX INDEX INDEX INDEX

2,055 I_WRI$_OPTSTAT_HH_ST INDEX 3,883 I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST INDEXNote that you cannot en able row movement and shrink the tables as the indexes are function based view sourceprint?1 alter table WRI$_OPTSTAT_IND_HISTORY enable row movement; 2 alter table WRI$_OPTSTAT_IND_HISTORY shrink space; 3 * 4 ERROR at line 1: 5 ORA-10631: SHRINK clause should not be specified for this object view sourceprint?1 select 'alter table ' segment_name ' move tablespace SYSAU X;' from dba_segments where tablespace_name = 'SYSAUX' 2 and segment_name like '%OPT%' and segment_type='TABLE' Run the rebuild table commands o fail note that this does cause any gather_stats jobs t

alter table WRI$_OPTSTAT_TAB_HISTORY move tablespace sysaux; alter table WRI$_OPTSTAT_IND_HISTORY move tablespace sysaux; alter table WRI$_OPTSTAT_HISTHEAD_HISTORY move tablespace sysaux; alter table WRI$_OPTSTAT_HISTGRM_HISTORY move tablespace sysaux; alter table WRI$_OPTSTAT_AUX_HISTORY move tablespace sysaux; alter table WRI$_OPTSTAT_OPR move tablespace sysaux; alter table WRH$_OPTIMIZER_ENV move tablespace sysaux;Script to generate rebuil d statements view sourceprint?1 select 'alter index ' segment_name ' rebuild online parall el (degree 14);' from dba_segments where tablespace_name = 'SYSAUX' 2 and segment_name like '%OPT%' and segment_type='INDEX' Once completed it is best to check that the indexes (indices) are usable view sourceprint?1 select di.index_name,di.index_type,di.status from dba_inde xes di , dba_tables dt 2 where di.tablespace_name = 'SYSAUX' 3 and dt.table_name = di.table_name 4 and di.table_name like '%OPT%' 5 order by 1 asc 6 /

S-ar putea să vă placă și