Oracle SQL调优系列之AWRDD报告简介

网友投稿 643 2022-05-30

我写的SQL调优专栏:https://blog.csdn.net/u014427391/article/category/8679315

整体分析调优工具

AWR:关注数据库的整体性能的报告;

ASH:数据库中的等待事件与哪些SQL具体对应的报告;

ADDM:oracle给出的一些建议

AWRDD:Oracle针对不同时段的性能对比报告

AWRSQRPT:oracle获取统计信息与执行计划

不同场景对应工具

局部分析调优工具:

explain plan for

set autotrace on

statistics_level=all

直接通过sql_id获取

10046 trace

awrrpt.sql

整体性能工具要点

AWR关注点:load profile、efficiency percentages、top 5 time events、SQL Statistics、segment_statistics

ASH关注点:等待事件与sql完美结合

ADDM:各种建议与对应SQL

AWRDD:不同时期 load profile的比较、不同时期等待事件的比较、不同时期TOP SQL的比较

AWRSQRPT:获取与关注点(统计信息与执行计划)

select output from table (dbms_workload_repository.awr_report_html(v_dbid,v_instance_number,v_min_snap_id,v_max_snap_id));

1

相关查询试图:

v$session (当前正在发生)

v$session_wait(当前正在等待)

v$session_wait_history (会话最近的10次等待事件)

v$active_session_history (内存中的ASH采集信息,理论为1小时)

wrh$_active_session_history (写入AWR库中的ASH信息,理论为1小时以上)

dba_hist_active_sess_history (根据wrh$_active_session_history生成的视图)

对于局部的,比如某个页面列表sql,我们可以使用Oracle的执行计划进行sql调优,但是对于整个系统来说,你可以知道哪些sql比较耗时?当然可以通过查Oracle的共享池得到,不过Oracle系统本身就提供了几种性能分析报告,比如AWR、ASH、ADDM、AWRDD等等报告,本博客介绍一下AWRDD性能分析报告

AWRDD报告是Oracle针对不同时段的性能的一个比对报告

一、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

1

查看用户

show parameter db_name

1

用登录之后才可以使用

plsql developer使用

plsql developer也可以使用,登录之后,选择文件(File)->新建(New)->命令窗口(Command Window)

1.2 自动创建快照

开始压测后执行

exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();

1

可以通过dba_hist_wr_control查看当前的配置情况,当前awr为每1小时做一次数据快照,保留时间为8天。

select * from dba_hist_wr_control;

1

修改配置,每隔30分钟收集一次,保存1天

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

1

关闭自动收集

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

1

1.3 手工创建快照

除了自动创建快照,也可以手工创建快照

select dbms_workload_repository.create_snapshot() from dual;

1

1.4 AWRDD报告生成

对于sqlplus客户端的可以使用

@?/rdbms/admin/awrddrpt.sql

1

对于plsql客户端,我用绝对路径去执行,@?的命令找不到文件

这个要根据自己的Oracle安装路径去修改,例如:

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

1

(1)快照报告格式

Enter value for report_type:html

有两种格式html和txt,这里选择html

(2)快照搜集天数

Enter value for num_days:1

快速搜集的天数,这里可以填个数字

(3)快照开始id1

Enter value for begin_snap:449

要根据日志打印的快照id范围来填,所以我可以填写:449

(4)快照结束id1

Enter value for end_snap:451

要根据日志打印的快照id范围来填,所以我可以填写:451

(5)快照收集天数2

Enter value for num_days2:1

快照收集天数,这里也可以填个数字,主要是来对比

(6)快速开始id2

Enter value for begin_snap2:450

也要在日志打印的范围内取:这里取450

(7)快照结束id2

Enter value for end_snap2:452

也要在日志打印的范围内取:这里取452

(8)AWRDD报告名称

Oracle SQL调优系列之AWRDD报告简介

Enter value for report_name

填写ADDM报告的名称,我可以填写awrdd_20190421.html,然后在打印的日志里有文件保存的路径:,比如:D:\oracle\product\11.2.0\dbhome_1\RDBMS\ADMIN\awrddm.html

SQL> @D:/oracle/product/11.2.0/dbhome_1/RDBMS/ADMIN/awrddrpt.sql Current Instance ~~~~~~~~~~~~~~~~ DBID DBID2 DB_NAME INST_ INST_ INST_NAME ---------- ---------- ------------ ----- ----- ------------ 1525762377 1525762377 ORCL 1 1 orcl rpt_options --------- 0 Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~ Would you like an HTML report, or a plain text report? Enter 'html' for an HTML report, or 'text' for plain text Defaults to 'html' Type Specified: html 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 Database Id and Instance Number for the First Pair of Snapshots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Using 1525762377 for Database Id for the first pair of snapshots Using 1 for Instance Number for the first pair of snapshots dbid --------- 1525762377 inst_num --------- 1 inst_num --------- 1 dbid --------- 1525762377 max_snap_time --------- 21/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 without specifying a number lists all completed snapshots. Listing the last day's Completed Snapshots INST_NAME DB_NAME SNAP_ID SNAPDAT LV ------------ ------------ -------- ------------------ -- orcl ORCL 448 21 Apr 2019 10:38 1 orcl ORCL 449 21 Apr 2019 12:00 1 orcl ORCL 450 21 Apr 2019 13:00 1 orcl ORCL 451 21 Apr 2019 14:00 1 orcl ORCL 452 21 Apr 2019 15:00 1 dbid --------- 1525762377 inst_num --------- 1 dbid --------- 1525762377 bid --------- 449 eid --------- 451 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 without specifying a number lists all completed snapshots. Listing the last day's Completed Snapshots INST_NAME DB_NAME SNAP_ID SNAPDAT LV ------------ ------------ -------- ------------------ -- orcl ORCL 448 21 Apr 2019 10:38 1 orcl ORCL 449 21 Apr 2019 12:00 1 orcl ORCL 450 21 Apr 2019 13:00 1 orcl ORCL 451 21 Apr 2019 14:00 1 orcl ORCL 452 21 Apr 2019 15:00 1 dbid2 --------- 1525762377 inst_num2 --------- 1 max_snap_time --------- 21/04/2019 inst_num2 --------- 1 dbid2 --------- 1525762377 max_snap_time --------- 21/04/2019 Specify the Second Pair of Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Second Begin Snapshot Id specified: 450 Second End Snapshot Id specified: 452 bid2 --------- 450 eid2 --------- 452 inst_num2 --------- 1 dbid2 --------- 1525762377 bid2 --------- 450 eid2 --------- 452 Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrdiff_1_449_1_450.html To use this name, press to continue, otherwise enter an alternative. Using the report name awrdd.html Started spooling to D:\oracle\product\11.2.0\dbhome_1\RDBMS\ADMIN\awrdd.html

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

二、AWRDD报告性能分析

AWRDD的报告分析和AWR有些是类似的,不过都是不同时期的

(1) AWRDD之不同时期的load profile

(2) AWRDD之不同时期的等待事件

(3) AWRDD不同时期的TOP SQL对比

Oracle SQL

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Orace SQL调优系列之ADDM报告简介
下一篇:仅用3年!跃升华为云教育类目伙伴TOP2
相关文章