SYSAUX 表空间过大,一般都是因为 WRH$_ACTIVE_SESSION_HISTORY 太大。

可以通过如下两种方法清理:

方法1:手动删除某范围的快照

SQL> exec DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE(2826,2832);


但是注意:
drop_snapshot_range 每次执行删除很少的几个快照,可能都非常非常慢,几个小时都没有执行出来。

方法2:

We have to manually purge the Optimizer Statistics, split the partitions of AWR objects and purge the AWR Snapshots manually.

1.) Run the below script to check the current space usage of Optimizer Statistics Histogram & AWR tables, its relevant
indexes in SYSAUX tablespace.

SQL> conn / as sysdba 
SQL> @?/rdbms/admin/awrinfo.sql 

Output is written to awrinfo.lst in the current working directory

2.) Check the statistics availablility from Optimizer Statistics Histogram table by number of days.

SQL> select systimestamp - min(savtime) from sys.wri$_optstat_histgrm_history; 

SYSTIMESTAMP-MIN(SAVTIME) 
---------------------------- 
+000000099 22:30:28.418491 

3.) Purge the Statistics by altering the number of days from the above query. i.e for this case the number of days are 99.

SQL> exec dbms_stats.purge_stats(sysdate - <no of days>); 

4.) Check the partition details for the table 'WRH$_ACTIVE_SESSION_HISTORY' before split.

SQL> set lines 150 
SQL> col SEGMENT_NAME for a30 
SQL> col PARTITION_NAME for a50 
SQL> SELECT owner, segment_name, partition_name, segment_type, bytes/1024/1024/1024 Size_GB FROM 
dba_segments WHERE segment_name='WRH$_ACTIVE_SESSION_HISTORY'; 

5.) Split the AWR partitions so that there is more chance of the smaller partition being purged:

SQL> alter session set "_swrf_test_action" = 72; 

Note: The above command will split partitions for ALL partitioned AWR objects. It also initiates a single split;
it does not need to be disabled and will need to be repeated if multiple splits are required.

6.) Check the partition details for the table 'WRH$_ACTIVE_SESSION_HISTORY' after split.

SQL> set lines 150 
SQL> col SEGMENT_NAME for a30 
SQL> col PARTITION_NAME for a50 
SQL> SELECT owner, segment_name, partition_name, segment_type, bytes/1024/1024/1024 Size_GB FROM 
dba_segments WHERE segment_name='WRH$_ACTIVE_SESSION_HISTORY'; 
-- By 许望(RHCA、OCM、VCP)
最后修改:2020 年 01 月 13 日 02 : 09 PM
如果觉得我的文章对你有用,请随意赞赏