Wednesday 14 September 2011

SYSAUX Tablespace Space Management

To see what is occupying most of the space in SYSAUX tablespace, you can run the following on the database:
@?/rdbms/admin/awrinfo.sql

The above will prompt for an output file. Once it finishes to run, review the file to see which component occupies the most space. To find out which component occupies the most space, scroll to section:

(1b) SYSAUX occupants space usage (v$sysaux_occupants)
********************************************************
|
| Occupant Name        Schema Name               Space Usage
| -------------------- -------------------- ----------------
| SM/OPTSTAT           SYS                       18,911.9 MB
| SM/AWR               SYS                          302.8 MB
| AO                   SYS                           56.8 MB
| XSOQHIST             SYS                           56.8 MB
| XDB                  XDB                           54.9 MB

...

If the SM/AWR is occuping the most space, then try to reduce the AWR retention.
We had a situation where SM/OPSTAT was taking up most of the space. The reason for this is that from 10g onwards, the database tries to retain backup of the object stats in the SYSAUX tablespace, the retention of this can be found by running following:

select dbms_stats.get_stats_history_retention from dual;

By default, the retention is for 31 days. To reduce this to 10days, you can run the following:

exec dbms_stats.alter_stats_history_retention(10);

After the above is run, you can let the default database stats job purge the object stats that are older than 31 days.

You may also find that after the purging is done, some of the objects still occupy a lot of space. You will need to shrink it.
Going through the report, we found the following objects were occupying the highest space:

(4) Space usage by non-AWR components (> 500K)
**********************************

COMPONENT        MB SEGMENT_NAME                                                          SEGMENT_TYPE
--------- --------- --------------------------------------------------------------------- ---------------
NON_AWR     7,171.0 SYS.WRI$_OPTSTAT_HISTHEAD_HISTORY                                     TABLE
NON_AWR     6,133.0 SYS.I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST                                     INDEX
NON_AWR     3,817.0 SYS.I_WRI$_OPTSTAT_HH_ST                                              INDEX
NON_AWR       391.0 SYS.WRI$_OPTSTAT_IND_HISTORY                                          TABLE
NON_AWR       339.0 SYS.I_WRI$_OPTSTAT_IND_ST                                             INDEX
NON_AWR       298.0 SYS.I_WRI$_OPTSTAT_IND_OBJ#_ST                                        INDEX
NON_AWR       204.0 SYS.I_WRI$_OPTSTAT_TAB_ST                                             INDEX
...

 In order to srhink the above, can we moved the SYS.WRI$_OPTSTAT_HISTHEAD_HISTORY table and rebuilt SYS.I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST, SYS.I_WRI$_OPTSTAT_HH_ST indexes:

alter table SYS.WRI$_OPTSTAT_HISTHEAD_HISTORY move;
alter index SYS.I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST rebuild;
alter index SYS.I_WRI$_OPTSTAT_HH_ST rebuild;

After doing the above, we were able to reclaim around 7GB of space.

No comments:

Post a Comment