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

user commits.WHAT DOES AWR COLLECTS AND PROCESSES 1. pl/sql execution time. Displayed in V$SYS_TIME_MODEL and V$SESS_TIME_MODEL view. 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. etc) operating system stats (avg_busy_ticks. avg_idle_ticks. java execution time. Time Model Statistics : Time usage for activities. • Metrics .collect stats over a period of time from the v$sysstat. etc) wait statistics ( db cpu. etc . Active Session History (ASH) statistics containing history of recent session activity. • Sampled data . Object Statistics : Determines both access and usage statistics of DB segments. etc) system stats session stats Database performance stats fall into one of three categories: Cumulative values . 5. app wait time.the ASH sampler is used to collect these stats. System & Session statistics collected in V$SYSSTAT & V$SESSSTAT . SQL statements those are causing highest load on system bsed on elapsed time and CPU usage.use the collected stats to make some sort of sense. • . 2. 3. 4.

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. lack of data will effect validity and accuracy of these components. 4. 1. 2. 3.SPACE CONSUMED BY AWR It is determined by several factors. Those are : 1. Rough space consumption by AWR is like 200-300 MB with default settings and 10 concurrent active sessions. Number of active sessions in the system in any given time. 3. Larger this period causes high space consumption. Historical data retention period. 2. 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 . By default data is collected in every 1 hour and stored for 7 days. This determines how long data is retained before being purged. Smaller interval leads to increase of volume of data. ** Active sessions can be selected from view V$SESSION where STATUS = ‘ACTIVE’ and USERNAME IS NOT NULL. . Snapshot Interval The frequency to capture snapshot. 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 .

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. show parameter statistics_level. To active the AWR change the system parameter statistics_level to one of three values • basic .this option disables the AWR • typical (default) . If its value is BASIC we can manually capture AWR using procedures in DBMS_WORKLOAD_REPOSITORY package. alter system set statistics_level = basic. It is important to create baselines from the AWR to capture typical performance periods.Oracle also recommends that one should never turn off the automatic snapshot collection as it effects the self management functionalities. . STATISTICS_LEVEL initialization should be TYPICAL OR ALL to enable AWR. But as BASIC value turnsoff collection of many system statistics the AWR will be incomplete. alter system set statistics_level = all.

END. For example: BEGIN DBMS_WORKLOAD_REPOSITORY. To view a list of the snapshot Ids along with database Ids. 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.CREATE_SNAPSHOT (). If you do not specify a value for dbid. For example. .DROP_SNAPSHOT_RANGE (low_snap_id => 22. END. In the example. dbid => 3310949047). Dropping Snapshots You can drop a range of snapshots using the DROP_SNAPSHOT_RANGE procedure. the range of snapshot Ids to drop is specified from 22 to 32. With it a snapshot for the instance is created immediately with the flush level specified to the default flush level of TYPICAL. the local database identifier is used as the default value.Managing Snapshot and Baseline Data with APIs The primary interface for managing the AWR is the Oracle Enterprise Manager Database Control. 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. We can view this snapshot in the DBA_HIST_SNAPSHOT view. check the DBA_HIST_SNAPSHOT view. you can drop the following range of snapshots: BEGIN DBMS_WORKLOAD_REPOSITORY. high_snap_id => 32. The optional database identifier is 3310949047. but monitoring functions can also be managed with procedures in the DBMS_WORKLOAD_REPOSITORY package .

The INTERVAL setting affects how often in minutes that snapshots are automatically generated. the local database identifier is used as the default value. end_snap_id => 280.CREATE_BASELINE (start_snap_id => 270. baseline_name => 'peak baseline'. In this example. For example: BEGIN DBMS_WORKLOAD_REPOSITORY.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 existing value is preserved. You can check the current settings for your database instance with the DBA_HIST_WR_CONTROL view. You can review the existing snapshots in the DBA_HIST_SNAPSHOT view to determine the range of snapshots that you want to use. dbid => 3310949047). To adjust the settings. END. If you do not specify a value for dbid. Creating and Dropping Baselines A baseline is created with the CREATE_BASELINE procedure. The RETENTION setting affects how long in minutes that snapshots are stored in the workload repository. 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.MODIFY_SNAPSHOT_SETTINGS ( retention => 43200. the retention period is specified as 43200 minutes (30 days) and the interval between each snapshot is specified as 30 minutes. use the MODIFY_SNAPSHOT_SETTINGS procedure. interval => 30. END. dbid => 3310949047). If NULL is specified. For example: BEGIN DBMS_WORKLOAD_REPOSITORY. The optional database identifier is 3310949047.

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. TRUE specifies that drop operation should remove the pair of snapshots associated with baseline along with the baseline. the local database identifier is used as the default value. The pair of snapshots associated with the baseline are retained until you explicitly drop the baseline. dbid => 3310949047). 270 is the start snapshot sequence number and 280 is the end snapshot sequence. If you do not specify a value for dbid. peak baseline is the name of baseline and FALSE specifies that only the baseline is dropped. For example: BEGIN DBMS_WORKLOAD_REPOSITORY.In this example. . peak baseline is the name of baseline and 3310949047 is an optional database identifier. In the example. cascade => FALSE. You can drop a baseline with the DROP_BASELINE procedure. END. 3310949047 is an optional database identifier.DROP_BASELINE (baseline_name => 'peak baseline'.

create_baseline (start_snap_id => 1070. high_snap_id => 1078).drop_baseline (baseline_name => 'Normal Baseline'. exec dbms_workload_repository. Snapshot Management exec dbms_workload_repository. baseline_name => 'Normal Baseline'). exec dbms_workload_repository. 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 .modify_snapshot_sett ings ( interval => 60. begin_interval_time. select snap_id. select table_name from dba_tables where tablespace_name = ‘SYSAUX’ and substr(table_name. retention => 43200).2) = ‘WR’ and rownum <= 20 order by 1. cascade => FALSE).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. exec dbms_workload_repository. end_interval_time from dba_hist_snapshot order by 1.create_snapshot. interval = minutes retention = seconds Display values select * from dba_hist_wr_control. 1. end_snap_id => 1078.drop_snapshot_range (low_snap_id => 1077.

sql . 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.To run AWR report you can use the following operating system scripts or use Enterprise Manager.

Sign up to vote on this title
UsefulNot useful