Detailed description of Oracle Database AWR instances

Source: Internet
Author: User

Last time we introduced:Oracle DatabaseMediumAWRIn this article, we will introduce the use of AWR in detail. Next, let's take a look at this part.

AWR is automatically generated by ORACLE, but you can also manually create, delete, and modify it using the DBMS_WORKLOAD_REPOSITORY package. You can run the desc command to view the process in the package. Below we will only introduce several common ones:

1. manually create a snapshot

 
 
  1. SQL> select count (*) from wrh $ _ active_session_history;
  2.  
  3. COUNT (*)
  4.  
  5. ----------
  6.  
  7. 317
  8.  
  9. SQL> begin
  10.  
  11. 2 dbms_workload_repository.create_snapshot ();
  12.  
  13. 3 end;
  14.  
  15. 4/
  16.  
  17. The PL/SQL process is successfully completed.
  18.  
  19. SQL> select count (*) from wrh $ _ active_session_history;
  20.  
  21. COUNT (*)
  22.  
  23. ----------
  24.  
  25. 320

2. manually delete snapshots of a specified range

 
 
  1. SQL> select * from wrh $ _ active_session_history where snap_id = 96;
  2.  
  3. SNAP_ID DBID INSTANCE_NUMBER SAMPLE_ID SAMPLE_TIME
  4.  
  5. -------------------------------------------------------------------------
  6.  
  7. 96 1160732652 1 236930 06-10-07 11.262.164.20.morning
  8.  
  9. 96 1160732652 1 236930 06-10-07 11.262.164.20.morning
  10.  
  11. 96 1160732652 1 236930 06-10-07 11.262.164.20.morning
  12.  
  13. SQL> begin
  14.  
  15. 2 dbms_workload_repository.drop_snapshot_range (low_snap_id = & gt; 96, high_snap_id = & gt; 96, dbid = & gt; 1160732652 );
  16.  
  17. 3 end;
  18.  
  19. 4/
  20.  
  21. The PL/SQL process is successfully completed.
  22.  
  23. SQL> select * from wrh $ _ active_session_history where snap_id = 96;
  24.  
  25. Unselected row

3. Modify the collection time and statistical information retention time

 
 
  1. PROCEDURE MODIFY_SNAPSHOT_SETTINGS
  2.  
  3. Parameter Name type input/output default value?
  4.  
  5. ---------------------------------
  6.  
  7. RETENTION NUMBER IN DEFAULT
  8.  
  9. INTERVAL NUMBER IN DEFAULT
  10.  
  11. TOPNSQL NUMBER IN DEFAULT
  12.  
  13. DBID NUMBER IN DEFAULT

You can modify the retention period of awr information by modifying the retention parameter. The default value is seven days, and the minimum value is one day. If the retention is set to zero, automatic cleanup is disabled. if awr finds that sysaux space is insufficient, it deletes the oldest snapshots to reuse the space. at the same time, a warning will be sent to the dba, telling the sysaux space is insufficient in the warning log ).

You can modify the interval parameter to modify the sampling frequency of awr information. The minimum value is 10 minutes, and the default value is 60 minutes. The typical values are 10, 20, 30, 60, 120, and so on. Set interval to 0 to disable automatic snapshot capturing. For example, change the collection interval to 30 minutes. And keep for 5 days. Note: The unit is minutes ):

 
 
  1. SQL> select * from dba_hist_wr_control;
  2.  
  3. DBID SNAP_INTERVAL RETENTION TOPNSQL
  4.  
  5. -----------------------------------------------------------------
  6.  
  7. 1160732652 + 00000 01:00:00. 0 + 00007 00:00:00. 0 DEFAULT
  8.  
  9. SQL> exec dbms_workload_repository.modify_snapshot_settings (interval => 30, retention => 5*24*60 );
  10.  
  11. The PL/SQL process is successfully completed.
  12.  
  13. SQL> SELECT * from dba_hist_wr_control;
  14.  
  15. DBID SNAP_INTERVAL RETENTION TOPNSQL
  16.  
  17. -----------------------------------------------------------------
  18.  
  19. 1160732652 + 00000 00:30:00. 0 + 00005 00:00:00. 0 DEFAULT
  20.  
  21. SQL>

4. Set baselines

Baseline) is a mechanism, so that you can mark the snapshot information set at an important time. A baseline is defined between one snapshot. snapshots are identified by their snapshot serial number. Each baseline has only one snapshot.

A typical performance tuning practice starts from collecting the baseline set of metrics, making changes, and then collecting another baseline set. You can compare the two sets to check the effect of the changes. In AWR, you can compare existing snapshots of the same type.

Assume that a highly resource-intensive process named apply_interest runs between and, corresponding to the snapshot ID 95 to 98. We can define a baseline named apply_interest_1 for these snapshots:

 
 
  1. SQL> select * From dba_hist_baseline;
  2.  
  3. Unselected row
  4.  
  5. SQL> select * from wrm $ _ baseline;
  6.  
  7. Unselected row
  8.  
  9. SQL> exec dbms_workload_repository.create_baseline (95, 98, 'apply _ interest_1 ');
  10.  
  11. The PL/SQL process is successfully completed.

This operation takes the snapshot number from 95 to 98 as part of the baseline specified above. View existing baselines:

 
 
  1. SQL> select * from dba_hist_baseline;
  2.  
  3. DBID BASELINE_ID BASELINE_NAME START_SNAP_ID START_SNAP_TIME END_SNAP_ID END_SNAP_TIME
  4.  
  5. -----------------------------------------------------------------------------------------------------------------------
  6.  
  7. 1160732652 1 apply_interest_1 95 06-10-07 11.0000005.375 am 98 06-10-07 01.44.58.062 pm
  8.  
  9. SQL> select * from wrm $ _ baseline;
  10.  
  11. DBID BASELINE_ID BASELINE_NAME START_SNAP_ID END_SNAP_ID
  12.  
  13. -------------------------------------------------------------------------
  14.  
  15. 1160732652 1 apply_interest_1 95 98
  16.  
  17. SQL>

After some adjustment steps, we can create another baseline-assuming the name is apply_interest_2, and then compare the measurement only for those snapshots related to the two baselines.

 
 
  1. SQL> exec dbms_workload_repository.create_baseline (92, 94, 'apply _ interest_2 ');
  2.  
  3. The PL/SQL process is successfully completed.

Separating snapshots in just a few sets like this helps research the impact of adjustment on performance metrics. You can use drop_baseline () to delete the baseline after analysis. Snapshots can be retained or deleted in cascade mode ). In addition, when the cleanup routine starts to delete the old snapshots, the snapshots related to the baseline are not cleared, allowing further analysis.

5. delete a baseline

To delete a baseline:

 
 
  1. SQL> exec dbms_workload_repository.drop_baseline (baseline_name => 'apply _ interest_1 ', cascade => false );
  2.  
  3. The PL/SQL process is successfully completed.
  4.  
  5. SQL> select * from wrh $ _ active_session_history where snap_id in (95,96, 97,98 );
  6.  
  7. SNAP_ID DBID INSTANCE_NUMBER SAMPLE_ID SAMPLE_TIME
  8.  
  9. ----------------------------------------------------------------------------
  10.  
  11. 95 1160732652 1 235360 06-10-07 10.56.29.872 AM
  12.  
  13. 95 1160732652 1 235230 06-10-07 10.54.19.857 AM
  14.  
  15. 95 1160732652 1 233130 06-10-07 10.19.19.478 AM
  16.  
  17. 95 1160732652 1 232830 06-10-07 10.14.18.859 AM
  18.  
  19. 95 1160732652 1 232250-07 10.04.38.481 AM
  20.  
  21. 97 1160732652 1 238600 06-10-07 12.33.08.420 pm
  22.  
  23. 97 1160732652 1 238600 06-10-07 12.33.08.420 pm
  24.  
  25. 97 1160732652 1 238600 06-10-07 12.33.08.420 pm
  26.  
  27. 97 1160732652 1 238600 06-10-07 12.33.08.420 pm
  28.  
  29. 97 1160732652 1 238600 06-10-07 12.33.08.420 pm
  30.  
  31. 97 1160732652 1 238600 06-10-07 12.33.08.420 pm
  32.  
  33. SNAP_ID DBID INSTANCE_NUMBER SAMPLE_ID SAMPLE_TIME
  34.  
  35. ----------------------------------------------------------------------------
  36.  
  37. 97 1160732652 1 238420 06-10-07 11.50.55.686 AM
  38.  
  39. 97 1160732652 1 238230 06-10-07 11.47.45.687 AM
  40.  
  41. 98 1160732652 1 239140 06-10-07 01.42.00.976 pm
  42.  
  43. 98 1160732652 1 239140 06-10-07 01.42.00.976 pm
  44.  
  45. 98 1160732652 1 239140 06-10-07 01.42.00.976 pm
  46.  
  47. 98 1160732652 1 239140 06-10-07 01.42.00.976 pm
  48.  
  49. 98 1160732652 1 239140 06-10-07 01.42.00.976 pm
  50.  
  51. 98 1160732652 1 239130 06-10-07 01.272.164.161 afternoon
  52.  
  53. 98 1160732652 1 239130 06-10-07 01.272.164.161 afternoon
  54.  
  55. 98 1160732652 1 239130 06-10-07 01.272.164.161 afternoon
  56.  
  57. 21 rows have been selected.
  58.  
  59. SQL> exec dbms_workload_repository.drop_baseline (baseline_name => 'apply _ interest_2 ', cascade => true );
  60.  
  61. The PL/SQL process is successfully completed.
  62.  
  63. SQL> select * from wrh $ _ active_session_history where snap_id in (92,93, 94 );
  64.  
  65. Unselected row
  66.  
  67. SQL>

The above are some detailed operations on the use of Oracle Database AWR. This article will introduce it here. I hope this introduction will be helpful to you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.