Oracle 优化篇+查看SQL的AWR报告

说明:本文为Oracle 11gR2中查看SQL的AWR报告的指导手册
用途:本文只是提供一种方法和思路,更多更高级的使用方法还期待你不断的探索哦
标签:查看SQL的AWR报告、WORKLOAD REPOSITORY SQL Report、awrsqrpt.sql、awrsqrpi.sql
温馨提示:如果您发现本文哪里写的有问题或者有更好的写法请留言或私信我进行修改优化


★ 执行测试SQL
※ 温馨提示:建议将测试SQL执行5次以上,否则AWR不会收集该SQL的信息
sqlplus / as sysdba
select /*tag zzt_005*/ *
  from scott.emp e, scott.dept d
 where e.deptno = d.deptno
   and empno > 7800;

★ 手动生成AWR快照
BEGIN
  DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/


★ 查看业务SQL信息(本例中SQL_ID:43c4xrbk0qdvc)
sqlplus / as sysdba
select * from v$sqlarea a where lower(a.SQL_TEXT) like '%/*tag zzt_005*/%';


★ 执行AWR脚本,查看特定SQL的AWR
@$ORACLE_HOME/rdbms/admin/awrsqrpt.sql    单实例
@$ORACLE_HOME/rdbms/admin/awrsqrpi.sql    自定义实例
具体使用方法:(略)


★ HTML输出案例截图

Oracle 优化篇+查看SQL的AWR报告_第1张图片

★ HTML输出案例

AWR SQL Report for DB: ORCL, Inst: ora11g, Snaps: 14-16, SQL Id: 43c4xrbk0qdvc

WORKLOAD REPOSITORY SQL Report

Snapshot Period Summary

DB NameDB IdInstanceInst numStartup TimeReleaseRAC
ORCL1462754487ora11g115-Feb-20 10:0211.2.0.3.0NO

Snap IdSnap TimeSessionsCursors/Session
Begin Snap:1420-May-20 13:19:1634 1.9
End Snap:1620-May-20 13:22:5532 1.9
Elapsed:  3.65 (mins)  
DB Time:  0.05 (mins)  

SQL Summary

SQL IdElapsed Time (ms)ModuleActionSQL Text
43c4xrbk0qdvc10 [email protected] (TNS V1-V3)   select /*tag zzt_005*/ * from scott.emp e, scott.dept d where e.deptno...


Back to Top

SQL ID: 43c4xrbk0qdvc

#Plan Hash ValueTotal Elapsed Time(ms)Executions1st Capture Snap IDLast Capture Snap ID
181778775910101616


Back to Top

Plan 1(PHV: 817787759)

Back to Top

Plan Statistics

  • % Total DB Time is the Elapsed Time of the SQL statement divided into the Total Database Time multiplied by 100
Stat NameStatement TotalPer Execution% Snap Total
Elapsed Time (ms)100.950.30
CPU Time (ms)80.800.24
Executions10  
Buffer Gets606.000.38
Disk Reads00.000.00
Parse Calls30.300.35
Rows606.00 
User I/O Wait Time (ms)0  
Cluster Wait Time (ms)0  
Application Wait Time (ms)0  
Concurrency Wait Time (ms)0  
Invalidations0  
Version Count1  
Sharable Mem(KB)27  

Back to Plan 1(PHV: 817787759)
Back to Top

Execution Plan

Id Operation Name Rows Bytes Cost (%CPU) Time
0 SELECT STATEMENT     5 (100) 
1    MERGE JOIN   3 174 5 (20) 00:00:01
2      TABLE ACCESS BY INDEX ROWID DEPT 4 80 2 (0) 00:00:01
3        INDEX FULL SCAN PK_DEPT 4   1 (0) 00:00:01
4      SORT JOIN   3 114 3 (34) 00:00:01
5        TABLE ACCESS BY INDEX ROWID EMP 3 114 2 (0) 00:00:01
6          INDEX RANGE SCAN PK_EMP 3   1 (0) 00:00:01

Back to Plan 1(PHV: 817787759)
Back to Top

Full SQL Text

SQL IdSQL Text
43c4xrbk0qdvcselect /*tag zzt_005*/ * from scott.emp e, scott.dept d where e.deptno = d.deptno and empno > 7800


Back to Top


 

※ 如果您觉得文章写的还不错, 别忘了在文末给作者点个赞哦 ~

over

 

你可能感兴趣的:(数据库+Oracle)