You are on page 1of 9

Statspack was introduced in oracle version 8.1.7 .

Automatic Workload Repository (AWR) was introduced with oracle version 10g. Both of them are very similar as both provides top-down look at performance statistics. WHAT IS AWR ::: It is a background process, set of tables and reports. It takes snapshots of statistics as well as high-cost SQL every hour. It collects , processes and monitors performance statistics for problem selection and self-tuning purposes. This generated data is stored in both memory and database that can be displayed in both reports and views. It automatically generate snapshots of performance data once every hour and collects statistics in the workload repository. If necessary we can even create snapshot for certain instances. The details are then analyzed in Automatic Database Diagnostic Monitor (ADDM) . AWR provides statistics in two formats
1. temporary - in memory collection of statistics in the SGA, accessible

via the V$ views 2. persistent - type of performance data in the form of regular AWR snapshots which you access via the DBA_ views

WHAT DOES AWR COLLECTS AND PROCESSES 1. Object Statistics : Determines both access and usage statistics of DB segments. 2. Time Model Statistics : Time usage for activities. Displayed in V$SYS_TIME_MODEL and V$SESS_TIME_MODEL view. 3. System & Session statistics collected in V$SYSSTAT & V$SESSSTAT . 4. SQL statements those are causing highest load on system bsed on elapsed time and CPU usage. 5. Active Session History (ASH) statistics containing history of recent session activity.
Tables that AWR uses to collect statistics v$sys_time_model v$osstat v$service_stats v$sysstat v$sesstat time model stats (db time, java execution time, pl/sql execution time, etc) operating system stats (avg_busy_ticks, avg_idle_ticks, etc) wait statistics ( db cpu, app wait time, user commits, etc) system stats session stats

Database performance stats fall into one of three categories: Cumulative values - collect stats over a period of time from the v$sysstat, etc . Metrics - use the collected stats to make some sort of sense. Sampled data - the ASH sampler is used to collect these stats.

SPACE CONSUMED BY AWR It is determined by several factors. 1. Number of active sessions in the system in any given time. 2. Snapshot Interval The frequency to capture snapshot. Smaller interval leads to increase of volume of data. 3. Historical data retention period. This determines how long data is retained before being purged. Larger this period causes high space consumption. By default data is collected in every 1 hour and stored for 7 days. Rough space consumption by AWR is like 200-300 MB with default settings and 10 concurrent active sessions. ** Active sessions can be selected from view V$SESSION where STATUS = ACTIVE and USERNAME IS NOT NULL. Note : Though we can reduce space consumption by reducing the interval and retention period many of oracles self-managing depends on AWR data for proper functioning . lack of data will effect validity and accuracy of these components. Those are : 1. 2. 3. 4. Automatic Database Diagnostic Monitor SQL Tuning Advisor Undo Advisor Segment Advisor

Oracle recommendation is to make the retention period large enough to capture one complete workload cycle . If the system experiences weekly workload cycles like OLTP or batch jobs during weekend there is no need to change the default settings but if the system is to face the same monthly then retention period should be increased to a month.

Oracle also recommends that one should never turn off the automatic snapshot collection as it effects the self management functionalities. It is important to create baselines from the AWR to capture typical performance periods. STATISTICS_LEVEL initialization should be TYPICAL OR ALL to enable AWR. If its value is BASIC we can manually capture AWR using procedures in DBMS_WORKLOAD_REPOSITORY package. But as BASIC value turnsoff collection of many system statistics the AWR will be incomplete. To active the AWR change the system parameter statistics_level to one of three values basic - this option disables the AWR typical (default) - activates standard level of collection all - same as typical but includes execution plans and timing info from the O/S
Active De-active Display alter system set statistics_level = typical; alter system set statistics_level = all; alter system set statistics_level = basic; show parameter statistics_level;

Managing Snapshot and Baseline Data with APIs


The primary interface for managing the AWR is the Oracle Enterprise Manager Database Control, but monitoring functions can also be managed with procedures in the DBMS_WORKLOAD_REPOSITORY package . Creating Snapshots You can manually create snapshots with the CREATE_SNAPSHOT procedure if you want to capture statistics at times different than those of the automatically generated snapshots. For example:
BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); END;

With it a snapshot for the instance is created immediately with the flush level specified to the default flush level of TYPICAL. We can view this snapshot in the DBA_HIST_SNAPSHOT view. Dropping Snapshots You can drop a range of snapshots using the DROP_SNAPSHOT_RANGE procedure. To view a list of the snapshot Ids along with database Ids, check the DBA_HIST_SNAPSHOT view. For example, you can drop the following range of snapshots:
BEGIN DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id => 22, high_snap_id => 32, dbid => 3310949047); END;

In the example, the range of snapshot Ids to drop is specified from 22 to 32. The optional database identifier is 3310949047. If you do not specify a value for dbid, the local database identifier is used as the default value. Active Session History data (ASH) that belongs to the time period specified by the snapshot range is also purged when the DROP_SNAPSHOT_RANGE procedure is called.

Modifying Snapshot Settings You can adjust the interval and retention of snapshot generation for a specified database Id, but note that this can affect the precision of the Oracle diagnostic tools. The INTERVAL setting affects how often in minutes that snapshots are automatically generated. The RETENTION setting affects how long in minutes that snapshots are stored in the workload repository. To adjust the settings, use the MODIFY_SNAPSHOT_SETTINGS procedure. For example:
BEGIN DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS ( retention => 43200, interval => 30, dbid => 3310949047); END;

In this example, the retention period is specified as 43200 minutes (30 days) and the interval between each snapshot is specified as 30 minutes. If NULL is specified, the existing value is preserved. The optional database identifier is 3310949047. If you do not specify a value for dbid, the local database identifier is used as the default value. You can check the current settings for your database instance with the DBA_HIST_WR_CONTROL view. Creating and Dropping Baselines A baseline is created with the CREATE_BASELINE procedure. A baseline is simply performance data for a set of snapshots that is preserved and used for comparisons with other similar workload periods when performance problems occur. You can review the existing snapshots in the DBA_HIST_SNAPSHOT view to determine the range of snapshots that you want to use. For example:
BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE (start_snap_id => 270, end_snap_id => 280, baseline_name => 'peak baseline', dbid => 3310949047); END;

In this example, 270 is the start snapshot sequence number and 280 is the end snapshot sequence. peak baseline is the name of baseline and 3310949047 is an optional database identifier. If you do not specify a value for dbid, the local database identifier is used as the default value. The system automatically assign a unique baseline Id to the new baseline when the baseline is created. The baseline Id and database identifier are displayed in the DBA_HIST_BASELINE view. The pair of snapshots associated with the baseline are retained until you explicitly drop the baseline. You can drop a baseline with the DROP_BASELINE procedure. For example:
BEGIN DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE (baseline_name => 'peak baseline', cascade => FALSE, dbid => 3310949047); END;

In the example, peak baseline is the name of baseline and FALSE specifies that only the baseline is dropped. TRUE specifies that drop operation should remove the pair of snapshots associated with baseline along with the baseline. 3310949047 is an optional database identifier.

To change the snapshot interval and how many days the snapshots are kept you use the package dbms_workload_repository or Enterprise Manager
Snapshot configuration exec dbms_workload_repository.modify_snapshot_sett ings ( interval => 60, retention => 43200); interval = minutes retention = seconds Display values select * from dba_hist_wr_control; Snapshot Management exec dbms_workload_repository.create_snapshot; exec dbms_workload_repository.drop_snapshot_range (low_snap_id => 1077, high_snap_id => 1078); exec dbms_workload_repository.create_baseline (start_snap_id => 1070, end_snap_id => 1078, baseline_name => 'Normal Baseline'); exec dbms_workload_repository.drop_baseline (baseline_name => 'Normal Baseline', cascade => FALSE); select snap_id, begin_interval_time, end_interval_time from dba_hist_snapshot order by 1; select table_name from dba_tables where tablespace_name = SYSAUX and substr(table_name, 1,2) = WR and rownum <= 20 order by 1; Useful Views dba_hist_active_sess_hist ASH info (see below) ory dba_hist_baseline baseline info dba_hist_database_instanc environment data e dba_hist_sql_plan dba_hist_wr_control dba_hist_snapshot sql execution path data AWR settings snapshot info in the AWR

Change snapshotting values

Create a snapshot Delete snapshots

Create a baseline

Delete a baseline

Display snapshots

View the repository tables

AWR Report

To run AWR report you can use the following operating system scripts or use Enterprise Manager.
the script will ask for begin snapshot and end snapshot and will be generated in text format Note: reports went in $oracle_home\db_1\bin awrrpti.sql the script will ask for begin snapshot and end snapshot and will be generated in HTML format Note: reports went in $oracle_home\db_1\bin

awrrpt.sql

You might also like