Professional Documents
Culture Documents
Automatic Workload Repository
Automatic Workload Repository
Automatic Workload Repository
Oracle have provided many performance gathering and reporting tools over
the years. Originally the UTLBSTAT/UTLESTAT scripts were used to
monitor performance metrics. Oracle8i introduced the Statspack
functionality which Oracle9i extended. In Oracle 10g statspack has evolved
into the Automatic Workload Repository (AWR).
AWR Features
Snapshots
By default snapshots of the relevant data are taken every hour and retained
for 7 days. The default values for these settings can be altered using:
BEGIN
DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings
(
retention => 43200, -- Minutes (= 30 Days). Current value
retained if NULL.
interval => 30); -- Minutes. Current value retained if
NULL.
END;
/
Extra snapshots can be taken and existing snapshots can be removed using:
EXEC DBMS_WORKLOAD_REPOSITORY.create_snapshot;
BEGIN
DBMS_WORKLOAD_REPOSITORY.drop_snapshot_range (
low_snap_id => 22,
high_snap_id => 32);
END;
/
Dropping Snapshots
Baselines
The pair of snapshots associated with a baseline are retained until the
baseline is explicitly deleted:
BEGIN
DBMS_WORKLOAD_REPOSITORY.drop_baseline (
baseline_name => 'batch baseline',
cascade => FALSE); -- Deletes associated snapshots if
TRUE.
END;
/
SQL script generates an HTML or text report that displays statistics for a
range of snapshot Ids for a specified database and instance.
The scripts prompt you to enter the report format (html or text), the start
snapshot id, the end snapshot id and the report filename. The resulting report
can be opend in a browser or text editor accordingly.
To generate a text report for a range of snapshot Ids, run the awrrpt.sql script
at the SQL prompt:
@$ORACLE_HOME/rdbms/admin/awrrpt.sql
First, you need to specify whether you want an HTML or a text report.
Enter value for report_type: text
Specify the number days for which you want to list snapshot Ids.
Enter value for num_days: 2
After the list displays, you are prompted for the beginning and ending
snapshot Id for the workload repository report.
Enter value for begin_snap: 150
Enter value for end_snap: 160
Next, accept the default report name or enter a report name. The default
name is accepted in the following example:
Enter value for report_name:
Using the report name awrrpt_1_150_160
This gives us the object ID, the relative file number, the block in the datafile,
and the row in the block that the session is waiting on. If that list of data
sounds familiar, it's because those are the four components of an extended
ROWID. We can build the row's actual extended ROWID from these
components using the DBMS_ROWID package. The ROWID_CREATE
function takes these arguments and returns the ROWID:
SQL> select do.object_name,
2 row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#,
3 dbms_rowid.rowid_create ( 1, ROW_WAIT_OBJ#,
ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# )
4 from v$session s, dba_objects do
5 where sid=543
6 and s.ROW_WAIT_OBJ# = do.OBJECT_ID ;
SELECT SQL_TEXT
FROM V$SQLAREA
WHERE (ADDRESS, HASH_VALUE) IN
(SELECT SQL_ADDRESS, SQL_HASH_VALUE
FROM V$SESSION
WHERE SID = &sid_number)
/