Oracle ADDM報告生成和性能分析


我寫的SQL調優專欄:https://blog.csdn.net/u014427391/article/category/8679315

對於局部的,比如某個頁面列表sql,我們可以使用Oracle的執行計划進行sql調優,但是對於整個系統來說,你可以知道哪些sql比較耗時?當然可以通過查Oracle的共享池得到,不過Oracle系統本身就提供了幾種性能分析報告,比如AWR、ASH、ADDM、AWRDD等等報告,本博客介紹一下ADDM性能分析報告

ADDM全稱是Automatic Database Diagnostic Monitor,是Oracle一個實現性能自我診斷的最佳利器。它依賴於AWR,也就是說ADDM要診斷,必要要有診斷的依據。在Oracle中,這個診斷依據就是Oracle AWR,因為Oracle AWR會定期的收集整個數據庫在運行期間的性能統計數據。

一、ADDM報告生成

繼之前AWR、ASH方面的博客之后,https://smilenicky.blog.csdn.net/article/details/89414432,https://smilenicky.blog.csdn.net/article/details/89419185,我再寫一篇ADDM方面的博客:

1.1 工具選擇

對於Oracle數據庫可以使用sqlplus或者plsql developer客戶端軟件
sqlplus 使用
可以使用sqlplus工具登錄
進入數據庫

sqlplus / as sysdba

查看用戶

show parameter db_name

用登錄之后才可以使用
plsql developer使用
plsql developer也可以使用,登錄之后,選擇文件(File)->新建(New)->命令窗口(Command Window)
在這里插入圖片描述

1.2 自動創建快照

開始壓測后執行

exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();

可以通過dba_hist_wr_control查看當前的配置情況,當前awr為每1小時做一次數據快照,保留時間為8天。

 select * from dba_hist_wr_control;

在這里插入圖片描述
修改配置,每隔30分鍾收集一次,保存1天

execute dbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>14000);

關閉自動收集

SQL>exec dbms_workload_repository.modify_snapshot_settings (interval=>0,retention=>24*60);

1.3 手工創建快照

除了自動創建快照,也可以手工創建快照

select dbms_workload_repository.create_snapshot() from dual;

1.4 ADDM報告生成

對於sqlplus客戶端的可以使用

@?/rdbms/admin/addmrpt.sql

對於plsql客戶端,我用絕對路徑去執行,@?的命令找不到文件
這個要根據自己的Oracle安裝路徑去修改,例如:

    @D:/oracle/product/11.1.0/db_1/RDBMS/ADMIN/addmrpt.sql

(1)快照開始id

Enter value for begin_snap:418

要根據日志打印的快照id范圍來填,所以我可以填寫:418

(2)快照結束id

Enter value for end_snap:420

要根據日志打印的快照id范圍來填,所以我可以填寫:420

(3)ADDM報告名稱

Enter value for report_name

填寫ADDM報告的名稱,我可以填寫addm_20190421.html,然后在打印的日志里有文件保存的路徑:,比如:D:\oracle\product\11.2.0\dbhome_1\RDBMS\ADMIN\addm.html

SQL> @D:/oracle/product/11.2.0/dbhome_1/RDBMS/ADMIN/addmrpt.sql
Current Instance
~~~~~~~~~~~~~~~~
      DBID DB_NAME      INST_ INST_NAME
---------- ------------ ----- ------------
1525762377 ORCL             1 orcl
Cannot SET TRIMSPOOL
Cannot SET UNDERLINE
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DBBID        INSTT DBB_NAME     INSTT_NAME   HOST
------------ ----- ------------ ------------ ------------
* 1525762377     1 ORCL         orcl         PC-201508171
                                             906
Using 1525762377 for database Id
Using 1 for instance number
PL/SQL procedure successfully completed
dbid
---------
1525762377
inst_num
---------
1
PL/SQL procedure successfully completed
inst_num
---------
1
dbid
---------
1525762377
max_snap_time
---------
18/04/2019
Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing <return> without
specifying a number lists all completed snapshots.
Listing the last 3 days of Completed Snapshots 
INST_NAME    DB_NAME       SNAP_ID SNAPDAT            LV
------------ ------------ -------- ------------------ --
orcl         ORCL              417 16 Apr 2019 00:00   1
orcl         ORCL              418 16 Apr 2019 19:48   1
orcl         ORCL              419 16 Apr 2019 21:00   1
orcl         ORCL              420 16 Apr 2019 22:00   1
orcl         ORCL              421 16 Apr 2019 23:00   1
orcl         ORCL              422 17 Apr 2019 21:20   1
orcl         ORCL              423 17 Apr 2019 22:00   1
orcl         ORCL              424 17 Apr 2019 23:00   1
orcl         ORCL              425 18 Apr 2019 00:00   1
orcl         ORCL              426 18 Apr 2019 21:26   1
orcl         ORCL              427 18 Apr 2019 22:00   1
11 rows selected
dbid
---------
1525762377
inst_num
---------
1
max_snap_time
---------
18/04/2019
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Begin Snapshot Id specified: 418
End   Snapshot Id specified: 420
PL/SQL procedure successfully completed
bid
---------
418
eid
---------
420
PL/SQL procedure successfully completed
inst_num
---------
1
dbid
---------
1525762377
bid
---------
418
eid
---------
420
Cannot SET TRIMSPOOL
Cannot SET UNDERLINE
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is addmrpt_1_418_420.txt.  To use this name,
press <return> to continue, otherwise enter an alternative.
Using the report name addm.html 
Running the ADDM analysis on the specified pair of snapshots ...
bid
---------
418
eid
---------
420
inst_num
---------
1
dbid
---------
1525762377
task_name
---------
TASK_953
Generating the ADDM report for this analysis ...
Started spooling to D:\oracle\product\11.2.0\dbhome_1\RDBMS\ADMIN\addm.html
          ADDM Report for Task 'TASK_953'
          -------------------------------
Analysis Period
---------------
AWR snapshot range from 418 to 420.
Time period starts at 16-APR-19 07.48.09 PM
Time period ends at 16-APR-19 10.00.20 PM
Analysis Target
---------------
Database 'ORCL' with DB ID 1525762377.
Database version 11.2.0.1.0.
ADDM performed an analysis of instance orcl, numbered 1 and hosted at
PC-201508171906.
Activity During the Analysis Period
-----------------------------------
Total database time was 57 seconds.
The average number of active sessions was .01.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are no findings to report.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          Additional Information
          ----------------------
Miscellaneous Information
-------------------------
There was no significant database activity to run the ADDM.
The database's maintenance windows were active during 99% of the analysis
period.
task_name
---------
TASK_953
Stopped spooling to D:\oracle\product\11.2.0\dbhome_1\RDBMS\ADMIN\addm.html
End of Report
Report written to addm.html.

二、ADDM報告性能分析

ADDM性能報告是從數據庫的整體配置和局部SQL方面給出建議,閱讀時候按FINDING1,FINDING2,...,的順序閱讀就好
在這里插入圖片描述

下面的圖來自《收獲,不止SQL優化》一書:
在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM