【11g】 管理自动工作负载存储库

本节描述如何管理AWR,并包含以下主题:

  • 管理快照
    管理基线
    基线管理模板
    传输自动工作负载存储库数据
    使用自动工作负载存储库视图
    生成自动工作负载存储库报告
    生成自动工作负载存储库比较周期报告
    生成活动会话历史记录报告
    使用活动会话历史记录报告

See Also:

"Overview of the Automatic Workload Repository" for a description of the AWR

5.3.1 Managing Snapshots

默认情况下,Oracle数据库每小时生成一次快照,并将统计信息保存在工作负载存储库中8天。必要时,可以使用DBMS_WORKLOAD_REPOSITORY过程手动创建、删除和修改快照。要调用这些过程,必须授予用户DBA角色。

管理快照的主要接口是Oracle Enterprise Manager。只要可能,您应该使用Oracle Enterprise Manager管理快照,如Oracle Database 2 Day + Performance Tuning Guide中所述。如果Oracle Enterprise Manager不可用,可以使用DBMS_WORKLOAD_REPOSITORY包管理快照,如下面的部分所述:

See Also:

扫描二维码关注公众号,回复: 6046174 查看本文章

5.3.1.1 Creating Snapshots

You can manually create snapshots with the CREATE_SNAPSHOT procedure to capture statistics at times different than those of the automatically generated snapshots. For example:

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:

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 Database diagnostic tools.

The INTERVAL setting affects how often the database automatically generates snapshots. The RETENTION setting affects how long the database stores snapshots 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, sharable Memory, and Version Count). The value for this setting is not 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 shared SQL area, though by doing so (or by setting the value to a very high number) may lead to possible space and performance issues because 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

本节描述如何管理基线。管理基线的主要接口是Oracle Enterprise Manager。只要可能,您应该使用Oracle Enterprise Manager管理基线,如Oracle Database 2 Day + Performance Tuning Guide中所述。如果Oracle Enterprise Manager不可用,您可以使用DBMS_WORKLOAD_REPOSITORY包管理基线,如下面的部分所述:

See Also:

5.3.2.1 Creating a Baseline

This section describes how to create a baseline using an existing range of snapshots.

To create a baseline:

  1. Review the existing snapshots in the DBA_HIST_SNAPSHOT view to determine the range of snapshots to use.

  2. 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, then 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:

  1. Review the existing baselines in the DBA_HIST_BASELINE view to determine the baseline to drop.

  2. 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, then the local database identifier is used as the default value.

5.3.2.3 Renaming a Baseline

This section describes how to rename a baseline.

To rename a baseline:

  1. Review the existing baselines in the DBA_HIST_BASELINE view to determine the baseline to rename.

  2. Use the RENAME_BASELINE procedure to rename the desired baseline:

    BEGIN
        DBMS_WORKLOAD_REPOSITORY.RENAME_BASELINE (
                       old_baseline_name => 'peak baseline', 
                       new_baseline_name => 'peak mondays', 
                       dbid => 3310949047);
    END;
    /
    

    In this example, the name of the baseline is renamed from peak baseline, as specified by the old_baseline_nameparameter, to peak mondays, as specified by the new_baseline_name parameter. The optional dbid parameter specifies the database identifier, which in this example is 3310949047. If you do not specify a value for dbid, then the local DBID is the default value.

5.3.2.4 Displaying Baseline Metrics

This section describes how to display metric threshold settings during the time period captured in a baseline. When used with adaptive thresholds, a baseline contains AWR data that the database can use to compute metric threshold values. The SELECT_BASELINE_METRICS function enables you to display the summary statistics for metric values in a baseline period.

To display metric information in a baseline:

  1. Review the existing baselines in the DBA_HIST_BASELINE view to determine the baseline for which you want to display metric information.

  2. Use the SELECT_BASELINE_METRICS function to display the metric information for the desired baseline:

    BEGIN
        DBMS_WORKLOAD_REPOSITORY.SELECT_BASELINE_METRICS (
                       baseline_name => 'peak baseline', 
                       dbid => 3310949047,
                       instance_num => '1');
    END;
    /
    

    In this example, the name of baseline is peak baseline. The optional dbid parameter specifies the database identifier, which in this example is 3310949047. If you do not specify a value for dbid, then the local database identifier is used as the default value. The optional instance_num parameter specifies the instance number, which in this example is 1. If you do not specify a value for instance_num, then the local instance is used as the default value.

5.3.2.5 Modifying the Window Size of the Default Moving Window Baseline

This section describes how to modify the window size of the default moving window baseline. For information about the default moving window baseline, see "Moving Window Baseline".

To resize the default moving window baseline, use the MODIFY_BASELINE_WINDOW_SIZE procedure:

BEGIN
    DBMS_WORKLOAD_REPOSITORY.MODIFY_BASELINE_WINDOW_SIZE (
                   window_size => 30, 
                   dbid => 3310949047);
END;
/

The window_size parameter is used to specify the new window size, in number of days, for the default moving window size. In this example, the window_size parameter is set to 30. The window size must be set to a value that is equal to or less than the value of the AWR retention setting. To set a window size that is greater than the current AWR retention period, you must first increase the value of the retention parameter, as described in "Modifying Snapshot Settings".

In this example, the optional dbid parameter specifies the database identifier is 3310949047. If you do not specify a value for dbid, then the local database identifier is used as the default value.

5.3.3 Managing Baseline Templates

本节描述如何管理基线模板。您可以使用基线模板自动创建基线来捕获未来指定的时间段。有关基线模板的信息,请参阅“基线模板”。

管理基线模板的主要接口是Oracle Enterprise Manager。只要可能,您应该使用Oracle Enterprise Manager管理基线模板,如Oracle Database 2 Day + Performance Tuning Guide中所述。如果Oracle Enterprise Manager不可用,您可以使用DBMS_WORKLOAD_REPOSITORY包管理基线模板,如下面的部分所述:

See Also:

Oracle Database PL/SQL Packages and Types Reference for detailed information on the DBMS_WORKLOAD_REPOSITORYpackage

5.3.3.1 Creating a Single Baseline Template

This section describes how to create a single baseline template. You can use a single baseline template to create a baseline during a single, fixed time interval in the future. For example, you can create a single baseline template to generate a baseline that is captured on April 2, 2009 from 5:00 p.m. to 8:00 p.m.

To create a single baseline template, use the CREATE_BASELINE_TEMPLATE procedure:

BEGIN
    DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE (
                   start_time => '2009-04-02 17:00:00 PST', 
                   end_time => '2009-04-02 20:00:00 PST', 
                   baseline_name => 'baseline_090402', 
                   template_name => 'template_090402', expiration => 30, 
                   dbid => 3310949047);
END;
/

The start_time parameter specifies the start time for the baseline to be created. The end_time parameter specifies the end time for the baseline to be created. The baseline_name parameter specifies the name of the baseline to be created. The template_nameparameter specifies the name of the baseline template. The optional expiration parameter specifies the expiration, in number of days, for the baseline. If unspecified, then the baseline never expires. The optional dbid parameter specifies the database identifier. If unspecified, then the local database identifier is used as the default value.

In this example, a baseline template named template_090402 is created that will generate a baseline named baseline_090402 for the time period from 5:00 p.m. to 8:00 p.m. on April 2, 2009 on the database with a database ID of 3310949047. The baseline will expire after 30 days.

5.3.3.2 Creating a Repeating Baseline Template

This section describes how to create a repeating baseline template. A repeating baseline template can be used to automatically create baselines that repeat during a particular time interval over a specific period in the future. For example, you can create a repeating baseline template to generate a baseline that repeats every Monday from 5:00 p.m. to 8:00 p.m. for the year 2009.

To create a repeating baseline template, use the CREATE_BASELINE_TEMPLATE procedure:

BEGIN
    DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE (
                   day_of_week => 'monday', hour_in_day => 17,
                   duration => 3, expiration => 30,
                   start_time => '2009-04-02 17:00:00 PST', 
                   end_time => '2009-12-31 20:00:00 PST', 
                   baseline_name_prefix => 'baseline_2009_mondays_', 
                   template_name => 'template_2009_mondays',
                   dbid => 3310949047);
END;
/

The day_of_week parameter specifies the day of the week on which the baseline will repeat. The hour_in_day parameter specifies the hour in the day when the baseline will start. The duration parameter specifies the duration, in number of hours, that the baseline will last. The expiration parameter specifies the number of days to retain each created baseline. If set to NULL, then the baselines never expires. The start_time parameter specifies the start time for the baseline to be created. The end_time parameter specifies the end time for the baseline to be created. The baseline_name_prefix parameter specifies the name of the baseline prefix that will be appended to the data information when the baseline is created. The template_name parameter specifies the name of the baseline template. The optional dbid parameter specifies the database identifier. If unspecified, then the local database identifier is used as the default value.

In this example, a baseline template named template_2009_mondays is created that will generate a baseline on every Monday from 5:00 p.m. to 8:00 p.m. beginning on April 2, 2009 at 5:00 p.m. and ending on December 31, 2009 at 8:00 p.m. on the database with a database ID of 3310949047. Each of the baselines will be created with a baseline name with the prefix baseline_2009_mondays_and will expire after 30 days.

5.3.3.3 Dropping a Baseline Template

This section describes how to drop an existing baseline template. Periodically, you may want to remove baselines templates that are no longer used to conserve disk space.

To drop a baseline template:

  1. Review the existing baselines in the DBA_HIST_BASELINE_TEMPLATE view to determine the baseline template you want to drop.

  2. Use the DROP_BASELINE_TEMPLATE procedure to drop the desired baseline template:

    BEGIN
      DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE_TEMPLATE (
                       template_name => 'template_2009_mondays',
                       dbid => 3310949047);
    END;
    /
    

    The template_name parameter specifies the name of the baseline template that will be dropped. In the example, the name of baseline template that will be dropped is template_2009_mondays. The optional dbid parameter specifies the database identifier, which in this example is 3310949047. If you do not specify a value for dbid, then the local database identifier is used as the default value.

5.3.4 Transporting Automatic Workload Repository Data

Oracle数据库允许您在系统之间传输AWR数据。这对于希望使用单独的系统执行AWR数据分析的情况非常有用。要传输AWR数据,必须先从源系统的数据库中提取AWR快照数据,然后将数据加载到目标系统的数据库中,如下所述:

5.3.4.1 Extracting AWR Data

The awrextr.sql script extracts the AWR data for a range of snapshots from the database into a Data Pump export file. After it is created, you can transport this dump file to another database where you can load the extracted data. To run the awrextr.sql script, you must be connected to the database as the SYS user.

To extract AWR data:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrextr.sql
    

    A list of the databases in the AWR schema is displayed.

  2. Specify the database from which the AWR data will be extracted:

    Enter value for db_id: 1377863381
    

    In this example, the database with the database identifier of 1377863381 is selected.

  3. 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.

  4. Define the range of snapshots for which AWR data will be extracted by specifying a beginning and ending snapshot ID:

    Enter value for begin_snap: 30
    Enter value for end_snap: 40
    

    In this example, the snapshot with a snapshot ID of 30 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 40 is selected as the ending snapshot.

  5. A list of directory objects is displayed.

    Specify the directory object pointing to the directory where the export dump file will be stored:

    Enter value for directory_name: DATA_PUMP_DIR
    

    In this example, the directory object DATA_PUMP_DIR is selected.

  6. Specify the prefix for name of the export dump file (the .dmp suffix will be automatically appended):

    Enter value for file_name: awrdata_30_40
    

    In this example, an export dump file named awrdata_30_40 will be created in the directory corresponding to the directory object you specified:

    Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
    C:\ORACLE\PRODUCT\11.1.0.5\DB_1\RDBMS\LOG\AWRDATA_30_40.DMP
    Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 08:58:20
    

    Depending on the amount of AWR data that must be extracted, the AWR extract operation may take a while to complete. After the dump file is created, you can use Data Pump to transport the file to another system.

See Also:

Oracle Database Utilities for information about using Data Pump

5.3.4.2 Loading AWR Data

After the export dump file is transported to the target system, you can load the extracted AWR data using the awrload.sql script. The awrload.sql script will first create a staging schema where the snapshot data is transferred from the Data Pump file into the database. The data is then transferred from the staging schema into the appropriate AWR tables. To run the awrload.sql script, you must be connected to the database as the SYS user.

To load AWR data:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrload.sql
    

    A list of directory objects is displayed.

  2. Specify the directory object pointing to the directory where the export dump file is located:

    Enter value for directory_name: DATA_PUMP_DIR
    

    In this example, the directory object DATA_PUMP_DIR is selected.

  3. Specify the prefix for name of the export dump file (the .dmp suffix will be automatically appended):

    Enter value for file_name: awrdata_30_40
    

    In this example, the export dump file named awrdata_30_40 is selected.

  4. Specify the name of the staging schema where the AWR data will be loaded:

    Enter value for schema_name: AWR_STAGE
    

    In this example, a staging schema named AWR_STAGE will be created where the AWR data will be loaded.

  5. Specify the default tablespace for the staging schema:

    Enter value for default_tablespace: SYSAUX
    

    In this example, the SYSAUX tablespace is selected.

  6. Specify the temporary tablespace for the staging schema:

    Enter value for temporary_tablespace: TEMP
    

    In this example, the TEMP tablespace is selected.

  7. A staging schema named AWR_STAGE will be created where the AWR data will be loaded. After the AWR data is loaded into the AWR_STAGE schema, the data will be transferred into the AWR tables in the SYS schema:

    Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    Completed 113 CONSTRAINT objects in 11 seconds
    Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
    Completed 1 REF_CONSTRAINT objects in 1 seconds
    Job "SYS"."SYS_IMPORT_FULL_03" successfully completed at 09:29:30
    ... Dropping AWR_STAGE user
    End of AWR Load
    

    Depending on the amount of AWR data that must be loaded, the AWR load operation may take a while to complete. After the AWR data is loaded, the staging schema will be dropped automatically.

5.3.5 Using Automatic Workload Repository Views

通常,您将通过Oracle Enterprise Manager或AWR报表查看AWR数据。不过,你也可以使用以下视图查看统计数字:

  • V$ACTIVE_SESSION_HISTORY

    This view displays active database session activity, sampled once every second. See "Active Session History".

  • V$ metric views provide metric data to track the performance of the system

    The metric views are organized into various groups, such as event, event class, system, session, service, file, and tablespace metrics. These groups are identified in the V$METRICGROUP view.

  • DBA_HIST views

    The DBA_HIST views displays historical data stored in the database. This group of views includes:

    • DBA_HIST_ACTIVE_SESS_HISTORY displays the history of the contents of the in-memory active session history for recent system activity

    • DBA_HIST_BASELINE displays information about the baselines captured on the system, such as the time range of each baseline and the baseline type

    • DBA_HIST_BASELINE_DETAILS displays details about a specific baseline

    • DBA_HIST_BASELINE_TEMPLATE displays information about the baseline templates used by the system to generate baselines

    • DBA_HIST_DATABASE_INSTANCE displays information about the database environment

    • DBA_HIST_DB_CACHE_ADVICE displays historical predictions of the number of physical reads for the cache size corresponding to each row

    • DBA_HIST_DISPATCHER displays historical information for each dispatcher process at the time of the snapshot

    • DBA_HIST_DYN_REMASTER_STATS displays statistical information about the dynamic remastering process

    • DBA_HIST_IOSTAT_DETAIL displays historical I/O statistics aggregated by file type and function

    • DBA_HIST_SHARED_SERVER_SUMMARY displays historical information for shared servers, such as shared server activity, common queues and dispatcher queues

    • DBA_HIST_SNAPSHOT displays information on snapshots in the system

    • DBA_HIST_SQL_PLAN displays the SQL execution plans

    • DBA_HIST_WR_CONTROL displays the settings for controlling AWR

      See Also:

      Oracle Database Reference for information about dynamic and static data dictionary views

5.3.6 Generating Automatic Workload Repository Reports

AWR报告显示在两个快照(或两个时间点)之间捕获的数据。AWR报告分为多个部分。HTML报告包含可用于在各节之间快速导航的链接。报告的内容包含所选快照范围的系统工作负载概要文件。

生成AWR报告的主要接口是Oracle Enterprise Manager。只要可能,您应该使用Oracle Enterprise Manager生成AWR报告,如Oracle Database 2 Day + Performance Tuning Guide中所述。如果Oracle Enterprise Manager不可用,可以通过运行SQL脚本生成AWR报告,如下面的部分所述:

To run these scripts, you must be granted the DBA role.

Note:

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.6.1 Generating an AWR Report

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:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrrpt.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: text
    

    In this example, a text report is chosen.

  3. 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.

  4. 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.

  5. 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.

5.3.6.2 Generating an Oracle RAC AWR Report

The awrgrpt.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot IDs using the current database identifier and all available database instances in an Oracle Real Application Clusters (Oracle RAC) environment.

Note:

In an Oracle RAC environment, you should always try to generate an HTML report (instead of a text report) because they are much easier to read.

To generate an AWR report in an Oracle RAC environment:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrgrpt.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. 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 day are displayed.

  4. 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.

  5. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrrpt_rac_150_160.html
    

    In this example, the default name is accepted and an AWR report named awrrpt_rac_150_160.html is generated.

5.3.6.3 Generating an AWR Report on a Specific Database Instance

The awrrpti.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot IDs using a specific database and instance. This script enables you to specify a database identifier and instance for which the AWR report will be generated.

To generate an AWR report on a specific database instance:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrrpti.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: text
    

    In this example, a text report is chosen.

    A list of available database identifiers and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
    
  3. Enter the values for the database identifier (dbid) and instance number (inst_num):

    Enter value for dbid: 3309173529
    Using 3309173529 for database Id
    Enter value for inst_num: 1
    
  4. 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.

  5. 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.

  6. 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 on the database instance with a database ID value of 3309173529.

5.3.6.4 Generating an Oracle RAC AWR Report on Specific Database Instances

The awrgrpti.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot IDs using specific databases and instances running in an Oracle RAC environment. This script enables you to specify database identifiers and a comma-delimited list of database instances for which the AWR report will be generated.

Note:

In an Oracle RAC environment, you should always try to generate an HTML report (instead of a text report) because they are much easier to read.

To generate an AWR report on a specific database instance in an Oracle RAC environment:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrgrpti.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

    A list of available database identifiers and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
     3309173529        2 TINT251      tint252      samp252
    
  3. Enter the value for the database identifier (dbid):

    Enter value for dbid: 3309173529
    Using 3309173529 for database Id
    
  4. Enter the value for the instance numbers (instance_numbers_or_all) of the Oracle RAC instances you want to include in the report:

    Enter value for instance_numbers_or_all: 1,2
    
  5. 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.

  6. 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.

  7. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrrpt_rac_150_160.html
    

    In this example, the default name is accepted and an AWR report named awrrpt_rac_150_160.html is generated on the database instance with a database ID value of 3309173529.

5.3.6.5 Generating an AWR Report for a SQL Statement

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.

To generate an AWR report for a particular SQL statement:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrsqrpt.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. Specify the number of days for which you want to list snapshot IDs.

    Enter value for num_days: 1
    

    A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the previous day are displayed.

  4. Specify a beginning and ending snapshot ID for the workload repository report:

    Enter value for begin_snap: 146
    Enter value for end_snap: 147
    

    In this example, the snapshot with a snapshot ID of 146 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 147 is selected as the ending snapshot.

  5. Specify the SQL ID of a particular SQL statement to display statistics:

    Enter value for sql_id: 2b064ybzkwf1y
    

    In this example, the SQL statement with a SQL ID of 2b064ybzkwf1y is selected.

  6. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrrpt_1_146_147.html
    

    In this example, the default name is accepted and an AWR report named awrrpt_1_146_147 is generated.

5.3.6.6 Generating an AWR Report for a SQL Statement on a Specific Database Instance

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 using a specific database and instance.This script enables you to specify a database identifier and instance for which the AWR report will be generated. Run this report to inspect or debug the performance of a SQL statement on a specific database and instance.

To generate an AWR report for a particular SQL statement on a specified database instance:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrsqrpi.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

    A list of available database identifiers and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
    
  3. Enter the values for the database identifier (dbid) and instance number (inst_num):

    Enter value for dbid: 3309173529
    Using 3309173529 for database Id
    Enter value for inst_num: 1
    Using 1 for instance number
    
  4. Specify the number of days for which you want to list snapshot IDs.

    Enter value for num_days: 1
    

    A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the previous day are displayed.

  5. Specify a beginning and ending snapshot ID for the workload repository report:

    Enter value for begin_snap: 146
    Enter value for end_snap: 147
    

    In this example, the snapshot with a snapshot ID of 146 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 147 is selected as the ending snapshot.

  6. Specify the SQL ID of a particular SQL statement to display statistics:

    Enter value for sql_id: 2b064ybzkwf1y
    

    In this example, the SQL statement with a SQL ID of 2b064ybzkwf1y is selected.

  7. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrrpt_1_146_147.html
    

    In this example, the default name is accepted and an AWR report named awrrpt_1_146_147 is generated on the database instance with a database ID value of 3309173529.

5.3.7 Generating Automatic Workload Repository Compare Periods Reports

While an AWR report shows AWR data between two snapshots (or two points in time), the AWR Compare Periods report shows the difference between two periods (or two AWR reports, which equates to four snapshots). Using the AWR Compare Periods report helps you to identify detailed performance attributes and configuration settings that differ between two time periods.

For example, if the application workload is known to be stable between 10:00 p.m. and midnight every night, but the performance on a particular Thursday was poor between 10:00 p.m. and 11:00 p.m., generating an AWR Compare Periods report for Thursday from 10:00 p.m. to 11:00 p.m. and Wednesday from 10:00 p.m. to 11:00 p.m. should identify configuration settings, workload profile, and statistics that were different in these time periods. Based on the differences, you can more easily diagnose the cause of the performance degradation. The two time periods selected for the AWR Compare Periods Report can be of different durations because the report normalizes the statistics by the amount of time spent on the database for each time period, and presents statistical data ordered by the largest difference between the periods.

The AWR Compare Periods 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 Compare Periods reports is Oracle Enterprise Manager. Whenever possible, you should generate AWR Compare Periods 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 Compare Periods reports by running SQL scripts, as described in the following sections:

To run these scripts, you must be granted the DBA role.

5.3.7.1 Generating an AWR Compare Periods Report

The awrddrpt.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods.

To generate an AWR Compare Periods report:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrddrpt.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. Specify the number of days for which you want to list snapshot IDs in the first time period.

    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.

  4. Specify a beginning and ending snapshot ID for the first time period:

    Enter value for begin_snap: 102
    Enter value for end_snap: 103
    

    In this example, the snapshot with a snapshot ID of 102 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 103 is selected as the ending snapshot for the first time period.

  5. Specify the number of days for which you want to list snapshot IDs in the second time period.

    Enter value for num_days2: 1
    

    A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the previous day are displayed.

  6. Specify a beginning and ending snapshot ID for the second time period:

    Enter value for begin_snap2: 126
    Enter value for end_snap2: 127
    

    In this example, the snapshot with a snapshot ID of 126 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 127 is selected as the ending snapshot for the second time period.

  7. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrdiff_1_102_1_126.txt
    

    In this example, the default name is accepted and an AWR report named awrdiff_1_102_126 is generated.

5.3.7.2 Generating an Oracle RAC AWR Compare Periods Report

The awrgdrpt.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods using the current database identifier and all available database instances in an Oracle RAC environment.

Note:

In an Oracle RAC environment, you should always try to generate an HTML report (instead of a text report) because they are much easier to read.

To generate an AWR Compare Periods report in an Oracle RAC environment:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrgdrpt.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. Specify the number of days for which you want to list snapshot IDs in the first time period.

    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.

  4. Specify a beginning and ending snapshot ID for the first time period:

    Enter value for begin_snap: 102
    Enter value for end_snap: 103
    

    In this example, the snapshot with a snapshot ID of 102 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 103 is selected as the ending snapshot for the first time period.

  5. Specify the number of days for which you want to list snapshot IDs in the second time period.

    Enter value for num_days2: 1
    

    A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the previous day are displayed.

  6. Specify a beginning and ending snapshot ID for the second time period:

    Enter value for begin_snap2: 126
    Enter value for end_snap2: 127
    

    In this example, the snapshot with a snapshot ID of 126 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 127 is selected as the ending snapshot for the second time period.

  7. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrracdiff_1st_1_2nd_1.html
    

    In this example, the default name is accepted and an AWR report named awrrac_1st_1_2nd_1.html is generated.

5.3.7.3 Generating an AWR Compare Periods Report on a Specific Database Instance

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. This script enables you to specify a database identifier and instance for which the AWR Compare Periods report will be generated.

To generate an AWR Compare Periods report on a specified database instance:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrddrpi.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: text
    

    In this example, a text report is chosen.

  3. A list of available database identifiers and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
    

    Enter the values for the database identifier (dbid) and instance number (inst_num) for the first time period:

    Enter value for dbid: 3309173529
    Using 3309173529 for Database Id for the first pair of snapshots
    Enter value for inst_num: 1
    Using 1 for Instance Number for the first pair of snapshots
    
  4. Specify the number of days for which you want to list snapshot IDs in the first time period.

    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.

  5. Specify a beginning and ending snapshot ID for the first time period:

    Enter value for begin_snap: 102
    Enter value for end_snap: 103
    

    In this example, the snapshot with a snapshot ID of 102 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 103 is selected as the ending snapshot for the first time period.

  6. Enter the values for the database identifier (dbid) and instance number (inst_num) for the second time period:

    Enter value for dbid2: 3309173529
    Using 3309173529 for Database Id for the second pair of snapshots
    Enter value for inst_num2: 1
    Using 1 for Instance Number for the second pair of snapshots
    
  7. Specify the number of days for which you want to list snapshot IDs in the second time period.

    Enter value for num_days2: 1
    

    A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the previous day are displayed.

  8. Specify a beginning and ending snapshot ID for the second time period:

    Enter value for begin_snap2: 126
    Enter value for end_snap2: 127
    

    In this example, the snapshot with a snapshot ID of 126 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 127 is selected as the ending snapshot for the second time period.

  9. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrdiff_1_102_1_126.txt
    

    In this example, the default name is accepted and an AWR report named awrdiff_1_102_126 is generated on the database instance with a database ID value of 3309173529.

5.3.7.4 Generating an Oracle RAC AWR Compare Periods Report on Specific Database Instances

The awrgdrpi.sql SQL script generates an HTML or text report that compares detailed performance attributes and configuration settings between two selected time periods using specific databases and instances in an Oracle RAC environment. This script enables you to specify database identifiers and a comma-delimited list of database instances for which the AWR Compare Periods report will be generated.

Note:

In an Oracle RAC environment, you should always try to generate an HTML report (instead of a text report) because they are much easier to read.

To generate an AWR Compare Periods report on a specified database instance in an Oracle RAC environment:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/awrgdrpi.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. A list of available database identifiers and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
     3309173529        2 TINT251      tint252      samp252
     3309173529        3 TINT251      tint253      samp253
     3309173529        4 TINT251      tint254      samp254
    

    Enter the values for the database identifier (dbid) and instance number (instance_numbers_or_all) for the first time period:

    Enter value for dbid: 3309173529
    Using 3309173529 for Database Id for the first pair of snapshots
    Enter value for inst_num: 1,2
    Using instances 1 for the first pair of snapshots
    
  4. Specify the number of days for which you want to list snapshot IDs in the first time period.

    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.

  5. Specify a beginning and ending snapshot ID for the first time period:

    Enter value for begin_snap: 102
    Enter value for end_snap: 103
    

    In this example, the snapshot with a snapshot ID of 102 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 103 is selected as the ending snapshot for the first time period.

  6. A list of available database identifiers and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
     3309173529        2 TINT251      tint252      samp252
     3309173529        3 TINT251      tint253      samp253
     3309173529        4 TINT251      tint254      samp254
    INSTNUM1
    -----------------------------------------------------
    1,2
    

    Enter the values for the database identifier (dbid2) and instance numbers (instance_numbers_or_all2) for the second time period:

    Enter value for dbid2: 3309173529
    Using 3309173529 for Database Id for the second pair of snapshots
    Enter value for instance_numbers_or_all2: 3,4
    
  7. Specify the number of days for which you want to list snapshot IDs in the second time period.

    Enter value for num_days2: 1
    

    A list of existing snapshots for the specified time range is displayed. In this example, snapshots captured in the previous day are displayed.

  8. Specify a beginning and ending snapshot ID for the second time period:

    Enter value for begin_snap2: 126
    Enter value for end_snap2: 127
    

    In this example, the snapshot with a snapshot ID of 126 is selected as the beginning snapshot, and the snapshot with a snapshot ID of 127 is selected as the ending snapshot for the second time period.

  9. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name awrracdiff_1st_1_2nd_1.html
    

    In this example, the default name is accepted and an AWR report named awrrac_1st_1_2nd_1.html is generated.

5.3.8 Generating Active Session History Reports

Use Active Session History (ASH) reports to perform analysis of:

  • Transient performance problems that typically last for a few minutes

  • Scoped or targeted performance analysis by various dimensions or their combinations, such as time, session, module, action, or SQL_ID

Transient performance problems are short-lived and do not appear in the Automatic Database Diagnostics Monitor (ADDM) analysis. ADDM tries to report the most significant performance problems during an analysis period in terms of their impact on DB time. If a particular problem lasts for a very short duration, then its severity might be averaged out or minimized by other performance problems in the analysis period. Therefore, the problem may not appear in the ADDM findings. Whether a performance problem is captured by ADDM depends on its duration compared to the interval between the AWR snapshots.

If a performance problem lasts for a significant portion of the time between snapshots, it will be captured by ADDM. For example, if the snapshot interval is set to one hour, a performance problem that lasts for 30 minutes should not be considered as a transient performance problem because its duration represents a significant portion of the snapshot interval and will likely be captured by ADDM.

However, a performance problem that lasts for only 2 minutes could be a transient performance problem because its duration represents a small portion of the snapshot interval and will likely not show up in the ADDM findings. For example, if the user notifies you that the system was slow between 10:00 p.m. and 10:10 p.m., but the ADDM analysis for the time period between 10:00 p.m. and 11:00 p.m. does not show a performance problem, a transient performance problem probably occurred that lasted for only a few minutes of the 10-minute interval reported by the user.

The ASH 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 ASH information used to identify blocker and waiter identities and their associated transaction identifiers and SQL for a specified duration. For more information on ASH, see "Active Session History".

The primary interface for generating ASH reports is Oracle Enterprise Manager. Whenever possible, you should generate ASH reports using Oracle Enterprise Manager, as described in Oracle Database 2 Day + Performance Tuning Guide. If Oracle Enterprise Manager is unavailable, you can generate ASH reports by running SQL scripts, as described in the following sections:

5.3.8.1 Generating an ASH Report

The ashrpt.sql SQL script generates an HTML or text report that displays ASH information for a specified duration.

To generate an ASH report:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/ashrpt.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: text
    

    In this example, a text report is chosen.

  3. Specify the begin time in minutes before the system date:

    Enter value for begin_time: -10
    

    In this example, 10 minutes before the current time is selected.

  4. Enter the duration in minutes that the report for which you want to capture ASH information from the begin time.

    Enter value for duration:
    

    In this example, the default duration of system date minus begin time is accepted.

  5. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name ashrpt_1_0310_0131.txt
    

    In this example, the default name is accepted and an ASH report named ashrpt_1_0310_0131 is generated. The report will gather ASH information beginning from 10 minutes before the current time and ending at the current time.

5.3.8.2 Generating an ASH Report on a Specific Database Instance

The ashrpti.sql SQL script generates an HTML or text report that displays ASH information for a specified duration for a specified database and instance. This script enables you to specify a database and instance before setting the time frame to collect ASH information.

To generate an ASH report on a specified database instance:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/ashrpti.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. A list of available database IDs and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
    

    Enter the values for the database identifier (dbid) and instance number (inst_num):

    Enter value for dbid: 3309173529
    Using 3309173529 for database id
    Enter value for inst_num: 1
    
  4. This step is applicable only if you are generating an ASH report on an Active Data Guard physical standby instance. If this is not the case, you may skip this step.

    To generate an ASH report on a physical standby instance, the standby database must be opened read-only. The ASH data on disk represents activity on the primary database and the ASH data in memory represents activity on the standby database.

    Specify whether to generate the report using data sampled from the primary or standby database:

    You are running ASH report on a Standby database.
    To generate the report over data sampled on the Primary database, enter 'P'.
    Defaults to 'S' - data sampled in the Standby database.
    Enter value for stdbyflag:
    Using Primary (P) or Standby (S): S
    

    In this example, the default value of Standby (S) is selected.

  5. Specify the begin time in minutes before the system date:

    Enter value for begin_time: -10
    

    In this example, 10 minutes before the current time is selected.

  6. Enter the duration in minutes that the report for which you want to capture ASH information from the begin time.

    Enter value for duration:
    

    In this example, the default duration of system date minus begin time is accepted.

  7. Specify the slot width in seconds that will be used in the Activity Over Time section of the report:

    Enter value for slot_width: 
    

    In this example, the default value is accepted. For more information about the Activity Over Time section and how to specify the slot width, see "Activity Over Time".

  8. Follow the instructions as explained in the subsequent prompts and enter values for the following report targets:

    • target_session_id

    • target_sql_id

    • target_wait_class

    • target_service_hash

    • target_module_name

    • target_action_name

    • target_client_id

    • target_plsql_entry

  9. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name ashrpt_1_0310_0131.txt
    

    In this example, the default name is accepted and an ASH report named ashrpt_1_0310_0131 is generated. The report will gather ASH information on the database instance with a database ID value of 3309173529 beginning from 10 minutes before the current time and ending at the current time.

5.3.8.3 Generating an Oracle RAC ASH Report

The ashrpti.sql SQL script generates an HTML or text report that displays ASH information for a specified duration for specified databases and instances in an Oracle RAC environment. Only ASH data that is written to disk will be used to generate the report. This report will only use ASH samples from the last 10 minutes that are found in the DBA_HIST_ACTIVE_SESS_HISTORY table.

To generate an ASH report in an Oracle RAC environment:

  1. At the SQL prompt, enter:

    @$ORACLE_HOME/rdbms/admin/ashrpti.sql
    
  2. Specify whether you want an HTML or a text report:

    Enter value for report_type: html
    

    In this example, an HTML report is chosen.

  3. A list of available database IDs and instance numbers are displayed:

    Instances in this Workload Repository schema
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       DB Id    Inst Num DB Name      Instance     Host
    ----------- -------- ------------ ------------ ------------
     3309173529        1 MAIN         main         examp1690
     3309173529        1 TINT251      tint251      samp251
     3309173529        2 TINT251      tint252      samp252
     3309173529        3 TINT251      tint253      samp253
     3309173529        4 TINT251      tint254      samp254
    

    Enter the values for the database identifier (dbid) and instance number (inst_num):

    Enter value for dbid: 3309173529
    Using database id: 3309173529
    Enter instance numbers. Enter 'ALL' for all instances in an Oracle
    RAC cluster or explicitly specify list of instances (e.g., 1,2,3).
    Defaults to current instance.
    Enter value for inst_num: ALL
    Using instance number(s): ALL
    
  4. Specify the begin time in minutes before the system date:

    Enter value for begin_time: -1:10
    

    In this example, 1 hour and 10 minutes before the current time is selected.

  5. Enter the duration in minutes that the report for which you want to capture ASH information from the begin time:

    Enter value for duration: 10
    

    In this example, the duration is set to 10 minutes.

  6. Specify the slot width in seconds that will be used in the Activity Over Time section of the report:

    Enter value for slot_width: 
    

    In this example, the default value is accepted. For more information about the Activity Over Time section and how to specify the slot width, see "Activity Over Time".

  7. Follow the instructions as explained in the subsequent prompts and enter values for the following report targets:

    • target_session_id

    • target_sql_id

    • target_wait_class

    • target_service_hash

    • target_module_name

    • target_action_name

    • target_client_id

    • target_plsql_entry

  8. Enter a report name, or accept the default report name:

    Enter value for report_name: 
    Using the report name ashrpt_rac_0310_0131.txt
    

    In this example, the default name is accepted and an ASH report named ashrpt_rac_0310_0131 is generated. The report will gather ASH information on all instances belonging to the database with a database ID value of 3309173529beginning from 1 hour and 10 minutes before the current time and ending at 1 hour before the current time.

5.3.9 Using Active Session History Reports

After generating an ASH report, you can review the contents to identify transient performance problems.

The contents of the ASH report are divided into the following sections:

See Also:

Oracle Real Application Clusters Administration and Deployment Guide for information about sections in the ASH report that are specific to Oracle Real Application Clusters (Oracle RAC)

5.3.9.1 Top Events

The Top Events section describes the top wait events of the sampled session activity categorized by user, background, and priority. Use the information in this section to identify the wait events that may be the cause of the transient performance problem.

The Top Events section contains the following subsections:

  • Top User Events

    This subsection lists the top wait events from user processes that accounted for the highest percentages of sampled session activity.

  • Top Background Events

    This subsection lists the top wait events from backgrounds that accounted for the highest percentages of sampled session activity.

  • Top Event P1/P2/P3

    This subsection lists the wait event parameter values of the top wait events that accounted for the highest percentages of sampled session activity, ordered by the percentage of total wait time (% Event). For each wait event, values in the P1 Value, P2 Value, P3 Value column correspond to wait event parameters displayed in the Parameter 1, Parameter 2, and Parameter 3 columns.

5.3.9.2 Load Profile

The Load Profile section describes the load analyzed in the sampled session activity. Use the information in this section to identify the service, client, or SQL command type that may be the cause of the transient performance problem.

The Load Profile section contains the following subsections:

  • Top Service/Module

    This subsection lists the services and modules that accounted for the highest percentages of sampled session activity.

  • Top Client IDs

    This subsection lists the clients that accounted for the highest percentages of sampled session activity based on their client ID, which is the application-specific identifier of the database session.

  • Top SQL Command Types

    This subsection lists the SQL command types, such as SELECT or UPDATE, that accounted for the highest percentages of sampled session activity.

  • Top Phases of Execution

    This subsection lists the phases of execution, such as SQL, PL/SQL, and Java compilation and execution, that accounted for the highest percentages of sampled session activity.

5.3.9.3 Top SQL

The Top SQL section describes the top SQL statements of the sampled session activity. Use this information to identify high-load SQL statements that may be the cause of the transient performance problem.

The Top SQL section contains the following subsections:

5.3.9.3.1 Top SQL with Top Events

The Top SQL with Top Events subsection lists the SQL statements that accounted for the highest percentages of sampled session activity and the top wait events that were encountered by these SQL statements. The Sampled # of Executions column shows how many distinct executions of a particular SQL statement were sampled.

5.3.9.3.2 Top SQL with Top Row Sources

The Top SQL with Top Row Sources subsection lists the SQL statements that accounted for the highest percentages of sampled session activity and their detailed execution plan information. You can use this information to identify which part of the SQL execution contributed significantly to the SQL elapsed time.

5.3.9.3.3 Top SQL Using Literals

The Top SQL Using Literals subsection lists the SQL statements using literals that accounted for the highest percentages of sampled session activity. You should review the statements listed in this report to determine whether the literals can be replaced with bind variables.

5.3.9.3.4 Top Parsing Module/Action

The Top Parsing Module/Action subsection lists the module and action that accounted for the highest percentages of sampled session activity while parsing the SQL statement.

5.3.9.3.5 Complete List of SQL Text

The Complete List of SQL Text subsection displays the entire text of the Top SQL statements shown in this section.

5.3.9.4 Top PL/SQL

The Top PL/SQL section lists the PL/SQL procedures that accounted for the highest percentages of sampled session activity. The PL/SQL Entry Subprogram column lists the application's top-level entry point into PL/SQL. The PL/SQL Current Subprogram column lists the PL/SQL subprogram being executed at the point of sampling. If the value of this column is SQL, then the % Current column shows the percentage of time spent executing SQL for this subprogram.

5.3.9.5 Top Java

The Top Java section describes the top Java programs in the sampled session activity.

5.3.9.6 Top Sessions

The Top Sessions section describes the sessions that were waiting for a particular wait event. Use this information to identify the sessions that accounted for the highest percentages of sampled session activity, which may be the cause of the transient performance problem.

The Top Sessions section contains the following subsections:

5.3.9.6.1 Top Sessions

The Top Session subsection lists the sessions that were waiting for a particular wait event that accounted for the highest percentages of sampled session activity.

5.3.9.6.2 Top Blocking Sessions

The Top Blocking Sessions subsection lists the blocking sessions that accounted for the highest percentages of sampled session activity.

5.3.9.6.3 Top Sessions Running PQs

The Top Sessions Running PQs subsection lists the sessions running parallel queries (PQs) that were waiting for a particular wait event, which accounted for the highest percentages of sampled session activity.

5.3.9.7 Top Objects/Files/Latches

The Top Objects/Files/Latches section provides additional information about the most commonly-used database resources and contains the following subsections:

5.3.9.7.1 Top DB Objects

The Top DB Objects subsection lists the database objects (such as tables and indexes) that accounted for the highest percentages of sampled session activity.

5.3.9.7.2 Top DB Files

The Top DB Files subsection lists the database files that accounted for the highest percentages of sampled session activity.

5.3.9.7.3 Top Latches

The Top Latches subsection lists the latches that accounted for the highest percentages of sampled session activity.

Latches are simple, low-level serialization mechanisms to protect shared data structures in the System Global Area (SGA). For example, latches protect the list of users currently accessing the database and the data structures describing the blocks in the buffer cache. A server or background process acquires a latch for a very short time while manipulating or looking at one of these structures. The implementation of latches is operating system-dependent, particularly regarding whether and how long a process waits for a latch.

5.3.9.8 Activity Over Time

The Activity Over Time section is one of the most informative sections of the ASH report. This section is particularly useful for longer time periods because it provides in-depth details about activities and workload profiles during the analysis period. The Activity Over Time section is divided into 10 time slots. The size of each time slot varies based on the duration of the analysis period. The first and last slots are usually odd-sized. All inner slots are equally sized and can be compared to each other. For example, if the analysis period lasts for 10 minutes, then all time slots will 1 minute each. However, if the analysis period lasts for 9 minutes and 30 seconds, then the outer slots may be 15 seconds each and the inner slots will be 1 minute each.

Each of the time slots contains information regarding that particular time slot, as described in Table 5-2.

Table 5-2 Activity Over Time

Column Description

Slot Time (Duration)

Duration of the slot

Slot Count

Number of sampled sessions in the slot

Event

Top three wait events in the slot

Event Count

Number of ASH samples waiting for the wait event

% Event

Percentage of ASH samples waiting for wait events in the entire analysis period

When comparing the inner slots, perform a skew analysis by identifying spikes in the Event Count and Slot Count columns. A spike in the Event Count column indicates an increase in the number of sampled sessions waiting for a particular event. A spike in the Slot Count column indicates an increase in active sessions, because ASH data is sampled from active sessions only and a relative increase in database workload. Typically, when the number of active session samples and the number of sessions associated with a wait event increases, the slot may be the cause of the transient performance problem.

To generate the ASH report with a user-defined slot size, run the ashrpti.sql script, as described in "Generating an ASH Report on a Specific Database Instance".

猜你喜欢

转载自blog.csdn.net/viviliving/article/details/89494255
今日推荐