The Automatic Workload Repository (AWR) collects, processes, and maintains performance statistics for problem detection and self-tuning purposes. This data is both in memory and stored in the database. The gathered data can be displayed in both reports and views.
The statistics collected and processed by AWR include:
Object statistics that determine both access and usage statistics of database segments
Time model statistics based on time usage for activities, displayed in the V$SYS_TIME_MODEL
and V$SESS_TIME_MODEL
views
Some of the system and session statistics collected in the V$SYSSTAT
and V$SESSTAT
views
SQL statements that are producing the highest load on the system, based on criteria such as elapsed time and CPU time
ASH statistics, representing the history of recent sessions activity
Gathering database statistics using the AWR is enabled by default and is controlled by the STATISTICS_LEVEL
initialization parameter. TheSTATISTICS_LEVEL
parameter should be set to the TYPICAL
or ALL
to enable statistics gathering by the AWR. The default setting is TYPICAL
. Setting STATISTICS_LEVEL
to BASIC
disables many Oracle Database features, including the AWR, and is not recommended. If STATISTICS_LEVEL
is set to BASIC
, you can still manually capture AWR statistics using the DBMS_WORKLOAD_REPOSITORY
package. However, because in-memory collection of many system statistics—such as segments statistics and memory advisor information—will be disabled, the statistics captured in these snapshots may not be complete. For information about the STATISTICS_LEVEL
initialization parameter, see Oracle Database Reference.
Oracle Database provides the initialization parameter STATISTICS_LEVEL
, which controls all major statistics collections or advisories in the database. This parameter sets the statistics collection level for the database.
Depending on the setting of STATISTICS_LEVEL
, certain advisories or statistics are collected, as follows:
BASIC
: No advisories or statistics are collected. Monitoring and many automatic features are disabled. Oracle does not recommend this setting because it disables important Oracle Database features.
TYPICAL
: This is the default value and ensures collection for all major statistics while providing best overall database performance. This setting should be adequate for most environments.(在生成ARW报告前,先检查参数STATISTICS_LEVEL,默认为TYPICAL即可)
ALL
: All of the advisories or statistics that are collected with the TYPICAL
setting are included, plus timed operating system statistics and row source execution statistics.
SQL> desc v$statistics_level; Name Type Nullable Default Comments -------------------- -------------- -------- ------- -------- STATISTICS_NAME VARCHAR2(64) Y DESCRIPTION VARCHAR2(4000) Y SESSION_STATUS VARCHAR2(8) Y SYSTEM_STATUS VARCHAR2(8) Y ACTIVATION_LEVEL VARCHAR2(7) Y STATISTICS_VIEW_NAME VARCHAR2(64) Y SESSION_SETTABLE VARCHAR2(3) Y
An AWR report shows data captured between two snapshots (or two points in time). The AWR reports are divided into multiple sections. The HTML report includes links that can be used to navigate quickly between sections. The content of the report contains the workload profile of the system for the selected range of snapshots.
The primary interface for generating AWR reports is Oracle Enterprise Manager. Whenever possible, you should generate AWR reports using Oracle Enterprise Manager, as described in Oracle Database 2 Day + Performance Tuning Guide(在OEM界面生成AWR).If Oracle Enterprise Manager is unavailable, you can generate AWR reports by running SQL scripts, as described in the following sections:
The awrrpt.sql
SQL script generates an HTML or text report that displays statistics for a range of snapshot IDs.
To generate an AWR report:
At the SQL prompt, enter:
@$ORACLE_HOME/rdbms/admin/awrrpt.sql
Specify whether you want an HTML or a text report:
Enter value for report_type: text
In this example, a text report is chosen.
Specify the number of days for which you want to list snapshot IDs.
Enter value for num_days: 2
A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the last 2 days are displayed.
Specify a beginning and ending snapshot ID for the workload repository report:
Enter value for begin_snap: 150 Enter value for end_snap: 160
In this example, the snapshot with a snapshot ID of 150 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 160 is selected as the ending snapshot.
Enter a report name, or accept the default report name:
Enter value for report_name: Using the report name awrrpt_1_150_160
In this example, the default name is accepted and an AWR report named awrrpt_1_150_160
is generated.
在该目录下@$ORACLE_HOME/rdbms/admin/以sysdba身份登录sqlplus
I:\app\Administrator\product\11.2.0\dbhome_1\RDBMS\ADMIN>sqlplus / as sysdba;
在sqlplus中输入@awrrpt
其它步骤同上。
注意:(两个snap id之间的时间必须是连续的,且不允许有停机)
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~
输入 begin_snap 的值: 1
Begin Snapshot Id specified: 1
输入 end_snap 的值: 18
End Snapshot Id specified: 18
===================
Generating an Oracle RAC AWR Report on Specific Database Instances
Generating an AWR Report for a SQL Statement on a Specific Database Instance
《FROM:转自ORACLE官方文档:http://docs.oracle.com/cd/E11882_01/server.112/e41573/autostat.htm#PFGRF94202》