AWR Snapshot Retention: Missing Automatic Space‑Based Purge Trigger for SYSAUX
0 reputation · 28 Feb 2025, 05:15 UTC
0 reputation · 28 Feb 2025, 05:15 UTC
Goal: Configure Oracle AWR to automatically purge the oldest snapshots when the SYSAUX tablespace free space falls below a defined threshold, ensuring continuous snapshot collection without manual intervention.
Currently, AWR retention is governed solely by a time‑based interval set through DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS; Oracle does not monitor SYSAUX usage to trigger snapshot deletion. When SYSAUX nears capacity, MMON may fail to write new snapshots, creating gaps in performance data until space is freed or retention is reduced. Administrators must manually run DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE or adjust retention to avoid overflow.
Is there a supported way to make AWR retention consider SYSAUX free space? Can a threshold be established via DBMS_WORKLOAD_REPOSITORY or another view to initiate automatic snapshot deletion? What are the compliance or audit implications of purging snapshots based on space rather than a fixed time interval?
34775 reputation · 28 Feb 2025, 08:02 UTC
Oracle Automatic Workload Repository (AWR) does not support a native, space-based trigger to purge snapshots. Retention is governed exclusively by a time-based interval configured via DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS. There is no internal parameter or threshold within the AWR framework that monitors SYSAUX free space to automatically initiate a purge.
The behavior described—where snapshots fail to write as SYSAUX nears capacity—is a result of tablespace exhaustion rather than a failure of a retention mechanism. Because AWR is not the sole occupant of the SYSAUX tablespace (which also houses Optimizer statistics and other auxiliary components), Oracle does not allow AWR to unilaterally purge data based on space, as this could lead to non-deterministic data loss that conflicts with the administrator's defined retention policy.
To achieve automatic purging based on space, you must implement a custom monitoring and maintenance loop using DBMS_SCHEDULER. The logic should follow these steps:
DBA_TABLESPACE_SPACE_USAGE or DBA_FREE_SPACE to determine the current percentage of free space in SYSAUX.snap_id range using DBA_HIST_SNAPSHOT and call DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE to remove the oldest snapshots.Moving from a fixed-time retention to a space-based purge introduces several risks:
DROP_SNAPSHOT_RANGE is a manual DDL-like operation, every automated purge must be logged to a custom audit table to track exactly which time ranges were deleted and why.To verify your current settings and space pressure, use the following queries:
-- Check current AWR retention settings
SELECT * FROM DBA_HIST_WR_CONTROL;
-- Check current SYSAUX space usage
SELECT tablespace_name, used_percent
FROM DBA_TABLESPACE_SPACE_USAGE
WHERE tablespace_name = 'SYSAUX';
Diagnostic Detail Needed: Are you using AUTOEXTEND on the SYSAUX datafiles? If AUTOEXTEND is enabled but limited by a MAXSIZE, the recommendation shifts toward increasing the physical disk allocation before implementing an automated purge script.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.