sqlmonitor for oracle,华丽丽的SQL报告:Oracle SQL Monitor Report

华丽丽的SQL报告:Oracle SQL Monitor Report

6ee5639a40442445944d63b514b2dd02.png

d3e73e5351d36bab86fbf00eca7d60cd.png

这个报告会通过OTN获得展现的框架和JS脚本,如果不能连接到公网,你可以在本地构建相应的文件,我在自己的站点保存了这些脚本:

mkdir -p eygle.com/sqlmon

cd eygle.com/sqlmon

wget --mirror --no-host-directories --cut-dirs=1 http://download.oracle.com/otn_software/emviewers/scripts/flashver.js

wget --mirror --no-host-directories --cut-dirs=1 http://download.oracle.com/otn_software/emviewers/scripts/loadswf.js

wget --mirror --no-host-directories --cut-dirs=1 http://download.oracle.com/otn_software/emviewers/scripts/document.js

wget --mirror --no-host-directories --cut-dirs=1 http://download.oracle.com/otn_software/emviewers/sqlmonitor/11/sqlmonitor.swf

这样我在生成SQL报告时,就可以调用自己网站的脚本文件。

通过v$sql_monitor视图可以找到已经被记录的SQL_ID:

SQL> select sql_id from v$sql_monitor;

SQL_ID

-------------

6rqxj647ut9pn

f4kcr0dn9rv6z

f6cz4n8y72xdc以下是通过脚本调用,生成了一个报告:

[eygle@enmoteam2 ~]$ sqlplus "/ as sysdba" @eygle.sql

SQL*Plus: Release 11.2.0.3.0 Production on Thu Sep 6 15:01:55 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options在脚本 eygle.sql 中定义了SQL_ID ,通过这个SQL_ID 生成了ACTIVE REPORT:

SET LONG 1000000

SET LONGCHUNKSIZE 1000000

SET LINESIZE 1000

SET PAGESIZE 0

SET TRIM ON

SET TRIMSPOOL ON

SET ECHO OFF

SET FEEDBACK OFF

SPOOL report_sql_monitor.htm

SELECT DBMS_SQLTUNE.report_sql_monitor(

sql_id       => '6rqxj647ut9pn',

type         => 'ACTIVE',

report_level => 'ALL',

base_path    => 'http://www.eygle.com/sqlmon') AS report

FROM dual;

SPOOL OFF这样生成的报告较以前的SQL Report更为直观。

以上优化的SQL,优化之前的执行计划有184个步骤,非常复杂:

7dbd44e8e8ffef728b3689dc992dc197.png

关于这个复杂SQL的演示,可以从以下链接获得:

http://www.eygle.com/sqlmon/report_sql_monitor_demo.htm

Kaya 在以前ACOUG的活动中曾经讲到过这个新特性,以下是2个来自Exadata中的测试SQL展现:

http://www.eygle.com/sqlmon/before.html

http://www.eygle.com/sqlmon/after.html

关于这个新特性的参考链接:

http://www.os2ora.com/use-sql-monitor-report-to-tune-and-diagnose-sql/

http://www.os2ora.com/fantastic-11gr2-sql-monitor-report/

http://www.oracle-base.com/articles/11g/real-time-sql-monitoring-11gr1.php

http://docs.oracle.com/cd/E11882_01/appdev.112/e16760/d_sqltun.htm

http://www.oracle.com/technetwork/database/focus-areas/manageability/sqlmonitor-084401.html

By eygle on 2012-09-07 08:30 |

Comments (0) |

SQL.PLSQL | 3043 |

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值