Awr Vs Ash
Awr Vs Ash
ASH can help you when there's a sudden performance degradation of the database felt.
AWR - historic past snapshot intervals.
AWR, stores the session performance statistics for analysis later.
ASH - the storage is not persistent and as time progresses, the old entries are removed to
accommodate new ones. They can be viewed using V$ACTIVE_SESSION_HISTORY
ASH report provides the below info.
Top Events
Load Profile
Top SQL
Top PL/SQL
Top Sessions
Top Objects/Files/Latches
Activity Over Time
AWR reports provide the below info.
Report Summary
Wait Events Statistics
SQL Statistics
Instance Activity Statistics
IO Stats
Buffer Pool Statistics
Advisory Statistics
Wait Statistics
Undo Statistics
Latch Statistics
Segment Statistics
Dictionary Cache Statistics
Library Cache Statistics
Memory Statistics
Streams Statistics
Resource Limit Statistics
init.ora Parameters
Wait Events
Time Model Statistics
Active Session History (ASH)
System and Session Statistics
5.1.1.1 Wait Events
Wait events are statistics that are incremented by a server process/thread to indicate that it had to
wait for an event to complete before being able to continue processing. Wait event data reveals
various symptoms of problems that might be impacting performance, such as latch contention, buffer
contention, and I/O contention.
To enable easier high-level analysis of the wait events, the events are grouped into classes. The wait
event classes include: Administrative, Application, Cluster, Commit, Concurrency, Configuration, Idle,
Network, Other, Scheduler, System I/O, and User I/O.
The wait classes are based on a common solution that usually applies to fixing a problem with the
wait event. For example, exclusive TX locks are generally an application level issue and HW locks are
generally a configuration issue.
The following list includes common examples of the waits in some of the classes:
Application: locks waits caused by row level locking or explicit lock commands
Commit: waits for redo log write confirmation after a commit
Idle: wait events that signify the session is inactive, such as SQL*Net message from client
Network: waits for data to be sent over the network
User I/O: wait for blocks to be read off a disk
See Also:
Oracle Database Reference for more information about Oracle wait events
5.1.1.2 Time Model Statistics
When tuning an Oracle system, each component has its own set of statistics. To look at the system as
a whole, it is necessary to have a common scale for comparisons. Because of this, most Oracle
advisories and reports describe statistics in terms of time. In addition, the V$SESS_TIME_MODEL
and V$SYS_TIME_MODEL views provide time model statistics. Using the common time
instrumentation helps to identify quantitative effects on the database operations.
The most important of the time model statistics is DB time. This statistics represents the total time
spent in database calls and is a indicator of the total instance workload. It is calculated by aggregating
the CPU and wait times of all sessions not waiting on idle wait events (non-idle user sessions).
DB time is measured cumulatively from the time that the instance was started. Because DB time it is
calculated by combining the times from all non-idle user sessions, it is possible that the DB time can
exceed the actual time elapsed since the instance started up. For example, a instance that has been
running for 30 minutes could have four active user sessions whose cumulative DB time is
approximately 120 minutes.
The objective for tuning an Oracle system could be stated as reducing the time that users spend in
performing some action on the database, or simply reducing DB time. Other time model statistics
provide quantitative effects (in time) on specific actions, such as logon operations and hard and soft
parses.
See Also:
Oracle Database Reference for information about the V$SESS_TIME_MODEL and
V$SYS_TIME_MODEL views
5.1.1.3 Active Session History (ASH)
The V$ACTIVE_SESSION_HISTORY view provides sampled session activity in the instance. Active
sessions are sampled every second and are stored in a circular buffer in SGA. Any session that is
connected to the database and is waiting for an event that does not belong to the Idle wait class is
considered as an active session. This includes any session that was on the CPU at the time of
sampling.
Each session sample is a set of rows and the V$ACTIVE_SESSION_HISTORY view returns one row
for each active session per sample, returning the latest session sample rows first. Because the active
session samples are stored in a circular buffer in SGA, the greater the system activity, the smaller the
number of seconds of session activity that can be stored in the circular buffer. This means that the
duration for which a session sample appears in the V$ view, or the number of seconds of session
activity that is displayed in the V$ view, is completely dependent on the database activity.
As part of the Automatic Workload Repository (AWR) snapshots, the content of
V$ACTIVE_SESSION_HISTORY is also flushed to disk. Because the content of this V$ view can get
quite large during heavy system activity, only a portion of the session samples is written to disk.
By capturing only active sessions, a manageable set of data is represented with the size being directly
related to the work being performed rather than the number of sessions allowed on the system. Using
the Active Session History enables you to examine and perform detailed analysis on both current data
in the V$ACTIVE_SESSION_HISTORY view and historical data in the
DBA_HIST_ACTIVE_SESS_HISTORY view, often avoiding the need to replay the workload to gather
additional performance tracing information. The data present in ASH can be rolled up on various
dimensions that it captures, including the following:
SQL identifier of SQL statement
Object number, file number, and block number
Wait event identifier and parameters
Session identifier and session serial number
Module and action name
Client identifier of the session
Service hash identifier
See Also:
Oracle Database Reference for more information about the V$ACTIVE_SESSION_HISTORY view
Active Session History information over a specified duration can be gathered into a report. For more
information, see "Generating Active Session History Reports".
5.1.1.4 System and Session Statistics
A large number of cumulative database statistics are available on a system and session level through
the V$SYSSTAT and V$SESSTAT views.
See Also:
Oracle Database Reference for information about the V$SYSSTAT and V$SESSTAT views
5.1.2 Operating System Statistics
Operating system statistics provide information on the usage and performance of the main hardware
components of the system, as well as the performance of the operating system itself. This information
is crucial for detecting potential resource exhaustion, such as CPU cycles and physical memory, and
for detecting bad performance of peripherals, such as disk drives.
Operating system statistics are only an indication of how the hardware and operating system are
working. Many system performance analysts react to a hardware resource shortage by installing more
hardware. This is a reactionary response to a series of symptoms shown in the operating system
statistics. It is always best to consider operating system statistics as a diagnostic tool, similar to the
way many doctors use body temperature, pulse rate, and patient pain when making a diagnosis. To
help identify bottlenecks, gather operating system statistics for all servers in the system under
performance analysis.
Operating system statistics include the following:
CPU Statistics
Virtual Memory Statistics
Disk Statistics
Network Statistics
For information on tools for gathering operating statistics, see "Operating System Data Gathering
Tools".
deallocate memory taken from the process heap. These statistics should be used to validate that
memory usage does not increase after the system has reached a steady state after startup. This
problem is particularly acute on shared server applications on middle tier systems where session state
may persist across user interactions, and on completion state information that is not fully deallocated.
5.1.2.3 Disk Statistics
Because the database resides on a set of disks, the performance of the I/O subsystem is very
important to the performance of the database. Most operating systems provide extensive statistics on
disk performance. The most important disk statistics are the current response time and the length of
the disk queues. These statistics show if the disk is performing optimally or if the disk is being
overworked.
Measure the normal performance of the I/O system; typical values for a single block read range from
5 to 20 milliseconds, depending on the hardware used. If the hardware shows response times much
higher than the normal performance value, then it is performing badly or is overworked. This is your
bottleneck. If disk queues start to exceed two, then the disk is a potential bottleneck of the system.
5.1.2.4 Network Statistics
Network statistics can be used in much the same way as disk statistics to determine if a network or
network interface is overloaded or not performing optimally. In today's networked applications,
network latency can be a large portion of the actual user response time. For this reason, these
statistics are a crucial debugging tool.
5.1.2.5 Operating System Data Gathering Tools
Table 5-1 shows the various tools for gathering operating statistics on UNIX. For Windows, use the
Performance Monitor tool.
Table 5-1 UNIX Tools for Operating Statistics
Component UNIX Tool
CPU
Memory
sar, vmstat
Disk
sar, iostat
Network
netstat
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/
In this example, a snapshot for the instance is created immediately with the flush level specified to the
default flush level of TYPICAL. You can view this snapshot in the DBA_HIST_SNAPSHOT view.
5.3.1.2 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:
10
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.
5.3.1.3 Modifying Snapshot Settings
You can adjust the interval, retention, and captured Top SQL 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.
The TOPNSQL setting affects the number of Top SQL to flush for each SQL criteria (Elapsed Time,
CPU Time, Parse Calls, Shareable Memory, and Version Count). The value for this setting will not be
affected by the statistics/flush level and will override the system default behavior for the AWR SQL
collection. It is possible to set the value for this setting to MAXIMUM to capture the complete set of
SQL in the cursor cache, though by doing so (or by setting the value to a very high number) may lead
to possible space and performance issues since there will more data to collect and store. To adjust
the settings, use the MODIFY_SNAPSHOT_SETTINGS procedure. For example:
BEGIN
DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 43200,
interval => 30, topnsql => 100, dbid => 3310949047);
END;
/
In this example, the retention period is specified as 43200 minutes (30 days), the interval between
each snapshot is specified as 30 minutes, and the number of Top SQL to flush for each SQL criteria
as 100. 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.
5.3.2 Managing Baselines
This section describes how to manage baselines. For more information about baselines, see
"Baselines".
The primary interface for managing snapshots is Oracle Enterprise Manager. Whenever possible, you
should manage snapshots using Oracle Enterprise Manager, as described in Oracle Database 2 Day
+ Performance Tuning Guide. If Oracle Enterprise Manager is unavailable, you can manage
snapshots using the DBMS_WORKLOAD_REPOSITORY package, as described in the following
sections:
Creating a Baseline
Dropping a Baseline
5.3.2.1 Creating a Baseline
11
This section describes how to create a baseline using an existing range of snapshots.
To create a baseline:
Review the existing snapshots in the DBA_HIST_SNAPSHOT view to determine the range of
snapshots that you want to use.
Use the CREATE_BASELINE procedure to create a baseline using the desired range of snapshots:
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE (start_snap_id => 270,
end_snap_id => 280, baseline_name => 'peak baseline',
dbid => 3310949047, expiration => 30);
END;
/
In this example, 270 is the start snapshot sequence number and 280 is the end snapshot sequence.
The name of baseline is peak baseline. 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. The optional
expiration parameter is set to 30, so the baseline will expire and be dropped automatically after 30
days. If you do not specify a value for expiration, the baseline will never expire.
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.
5.3.2.2 Dropping a Baseline
This section describes how to drop an existing baseline. Periodically, you may want to drop a baseline
that is no longer used to conserve disk space. The snapshots associated with a baseline are retained
indefinitely until you explicitly drop the baseline or the baseline has expired.
To drop a baseline:
Review the existing baselines in the DBA_HIST_BASELINE view to determine the baseline that you
want to drop.
Use the DROP_BASELINE procedure to drop the desired baseline:
BEGIN
DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE (baseline_name => 'peak baseline',
cascade => FALSE, dbid => 3310949047);
END;
/
In the example, the name of baseline is peak baseline. The cascade parameter is set to FALSE,
which specifies that only the baseline is dropped. Setting this parameter to TRUE specifies that the
drop operation will also remove the snapshots associated with the baseline. The optional dbid
parameter specifies the database identifier, which in this example is 3310949047. If you do not specify
a value for dbid, the local database identifier is used as the default value.
5.3.3 Transporting Automatic Workload Repository Data
Oracle Database enables you to transport AWR data between systems. This is useful in cases where
you want to use a separate system to perform analysis of the AWR data. To transport AWR data, you
need to first extract the AWR snapshot data from the database on the source system, then load the
data into the database on the target system, as described in the following sections:
12
@$ORACLE_HOME/rdbms/admin/awrextr.sql
A list of the databases in the AWR schema is displayed.
Specify the database from which the AWR data will be extracted:
13
In this example, an export dump file named awrdata_30_40 will be created in the directory
corresponding to the directory object you specified:
@$ORACLE_HOME/rdbms/admin/awrload.sql
A list of directory objects is displayed.
Specify the directory object pointing to the directory where the export dump file is located:
14
15
Oracle Database Reference for information on dynamic and static data dictionary views
5.3.5 Generating Automatic Workload Repository Reports
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. If Oracle Enterprise Manager is unavailable, you can generate
AWR reports by running SQL scripts:
The awrrpt.sql SQL script generates an HTML or text report that displays statistics for a range of
snapshot Ids.
The awrrpti.sql SQL script generates an HTML or text report that displays statistics for a range of
snapshot Ids on a specified database and instance.
The awrsqrpt.sql SQL script generates an HTML or text report that displays statistics of a particular
SQL statement for a range of snapshot Ids. Run this report to inspect or debug the performance of a
SQL statement.
The awrsqrpi.sql SQL script generates an HTML or text report that displays statistics of a particular
SQL statement for a range of snapshot Ids on a specified database and instance. Run this report to
inspect or debug the performance of a SQL statement on a specific database and instance.
The awrddrpt.sql SQL script generates an HTML or text report that compares detailed performance
attributes and configuration settings between two selected time periods.
The awrddrpi.sql SQL script generates an HTML or text report that compares detailed performance
attributes and configuration settings between two selected time periods on a specific database and
instance.
Note:
To run these scripts, you must be granted the DBA role. If you run a report on a database that does
not have any workload activity during the specified range of snapshots, calculated percentages for
some report statistics can be less than 0 or greater than 100. This result simply means that there is no
meaningful value for the statistic.
5.3.5.1 Running the awrrpt.sql Report
To generate an HTML or 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.
16
@$ORACLE_HOME/rdbms/admin/awrrpti.sql
First, specify whether you want an HTML or a text report. After that, a list of the database identifiers
and instance numbers displays, similar to the following:
@$ORACLE_HOME/rdbms/admin/awrsqrpt.sql
First, you need to specify whether you want an HTML or a text report.
17
@$ORACLE_HOME/rdbms/admin/awrsqrpi.sql
First, you need to specify whether you want an HTML or a text report.
18
@$ORACLE_HOME/rdbms/admin/awrddrpt.sql
First, you need to specify whether you want an HTML or a text report.
19
@$ORACLE_HOME/rdbms/admin/awrddrpi.sql
First, you need to specify whether you want an HTML or a text report.
20
@$ORACLE_HOME/rdbms/admin/ashrpt.sql
First, you need to specify whether you want an HTML or a text report.
21
@$ORACLE_HOME/rdbms/admin/ashrpti.sql
First, specify whether you want an HTML or a text report. After that, a list of the database Ids and
instance numbers displays, similar to the following:
22