Monday 19 December 2016

AWR snapshot reports and AWR retention period settings?

The dba_hist_wr_control table shows the AWR snapshot settings, namely the snapshot interval, the retention period and the top-x-sql collection threshold:
SQL> desc dba_hist_wr_control
Name                            Null?    Type
------------------------------- -------- ----------------------------
DBID                            NOT NULL NUMBER
SNAP_INTERVAL NOT               NULL     INTERVAL DAY(5) TO SECOND(1)
RETENTION                       NOT NULL INTERVAL DAY(5) TO SECOND(1)
TOPNSQL                                  VARCHAR2(10)


Scheduling the AWR snapshot collection

Oracle uses the MMON background process to collect AWR statistics. You can disable this job by changing the parameter STATISTICS_LEVEL to BASIC then snapshots will not be taken automatically.

SQL> show parameter statistics_level

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------
statistics_level                     string      BASIC

You can re-enable this job by changing the parameter STATISTICS_LEVEL to TYPICAL then snapshots will be taken automatically.
AWR Snapshot Reports
Oracle provides reports that you can run to analyze the data in the AWR.  There are two reports: awrrpt.sql and awrrpti.sql, which are available in the directory $ORACLE_HOME/rdbms/admin.
The output of these reports is essentially the same, except that awrrpti.sqlscript allows you to define a specific instance to report on.
The reports are much like the statspack reports of old, in that you define a beginning and ending snapshot ID, and the output filename of the report. Additionally, you can opt to produce the report in either text format or HTML format.

AWR Retention Period Settings

Setting an appropriate retention interval for your AWR is critical for proper data retention, especially for predictive modeling. You can adjust the AWR retention period according to your analysis needs.
In this example the retention period is specified as 3 years (1,576,800 minutes) and the interval between each snapshot is 60 minutes.
execute dbms_workload_repository.modify_snapshot_settings (
interval => 60,
retention => 1576800);
Oracle has published suggested storage requirements for AWR based on the activity and complexity of your 10g database:
Active Sessionsnumber of
CPU's (num_cpus)
number of
schema objects
Monthly
space required (gig)
Small1025002
Medium2085,0008
Large1003250,00020
Here, we choose out approximate database size and see estimated space for the AWR dba_hist tables. Oracle provides the SYSAUX sizing utility called utlsyxsz.sql (in $ORACLE_HOME/rdbms/admin) for estimating your AWR retention based on disk space consumption.
AWR also supports the creation of "AWR baselines", which are a "named" series of AWR snapshots that are immune from being purged by the AWR retention mechanism. the create_baseline procedure allows you to specify a start_snapshot and end_snapshot and name the baseline:
DBMS_WORKLOAD_REPOSITORY.create_baseline
(1900, 2000, 'EOY_PEAK_LOADS');

The dbms_workload_repository package can be used by Oracle DBAs to configure AWR settings such as snapshot interval, flushing and data retention.
The dbms_workload_repository .modify_snapshot_settings procedure is used to configure AWR data retention in the database. The retention interval determines the length of time that data will be preserved in the AWR. The default setting for retention is 10,080 minutes (one week).
desc dbms_workload_repository

PROCEDURE MODIFY_SNAPSHOT_SETTINGS
Argument Name Type In/Out Default?
------------------------------ ----------- ------ -------- RETENTION NUMBER IN DEFAULT INTERVAL NUMBER IN DEFAULT DBID NUMBER IN DEFAULT
The range of valid values for this parameter ranges from ten minutes to 52,560,000 minutes or 100 years.
The dbms_workload_repository package contains the global variables of min_retention and max_retention. These variables set the lower and upper limits for the retention parameter.

If a zero value is specified for retention, snapshots will be stored for an unlimited amount of time. The following awr_settings.sql script can be used to check the current settings for the AWR interval and retention settings:

3 comments:

  1. Once i updated the AWR retention then i see old snapshots are not getting deleted/purged. What can be the reason ? If you can help here

    ReplyDelete