ID 1380492.1 Monitoring SQL statements with Real-Time SQL Monitoring

ID 1380492.1 Monitoring SQL statements with Real-Time SQL Monitoring

The Oracle 11g Database has a new interface to monitor long running SQL commands.The feature is called Real-Time SQL Monitoring. By default, SQL monitoring is automatically started when a SQL command runs parallel, or when it has consumed at least five seconds of the CPU or I/O time in a single execution.You can also use the MONITOR hint to switch on SQL Monitoring.

SQL monitoring requires the STATISTICS_LEVEL parameter to be set to 'TYPICAL' or 'ALL', 
and the CONTROL_MANAGEMENT_PACK_ACCESS parameter set to  'DIAGNOSTIC+TUNING'.

The Real-Time SQL Monitoring feature is licensed with Diagnostics and Tuning Pack.

After monitoring is initiated, an entries are added to the dynamic performance V$SQL_MONITOR and V$SQL_PLAN_MONITOR views. This entry tracks key performance metrics collected for the execution, including the elapsed time, CPU time, number of reads and writes, I/O wait time, and various other wait times.These statistics are refreshed in near real time as the command executes, generally once every second.

After the execution ends, monitoring information is not deleted immediately, but is kept in the V$SQL_MONITOR/V$SQL_PLAN_MONITOR view for at least one minute.The entry is eventually deleted so its space can be reclaimed as new commands are monitored. 

You can find more details in the attached white paper.

DBMS_SQLTUNE.REPORT_SQL_MONITOR

The REPORT_SQL_MONITOR function is used to return a SQL monitoring report for a specific SQL statement. The SQL statement can be identified using a variety of parameters.
The function accepts some optional parameters, the  most common ones are:.
  • SQL_ID - The SQL_ID of the query of interest. When NULL (the default) the last monitored statement is targeted.

  • REPORT_LEVEL - The amount of information displayed in the report.
    The basic allowed values are 'NONE', 'BASIC', 'TYPICAL' or 'ALL',
    The default is 'TYPICAL' which is sufficent in most cases.

  • TYPE - The format used to display the report ('TEXT', 'HTML', 'XML' or 'ACTIVE').
    The 'ACTIVE' parameter is new in Oracle 11g Release 2 and displays the output using HTML and Flash. An Internet connection is needed to use the 'ACTIVE' parameter.

  • SESSION_ID - Targets a subset of queries based on the specified SID.
    Use SYS_CONTEXT('USERENV','SID') for the current session.
    The default is NULL.
Following is an example using REPORT_SQL_MONITOR:
SET LONG 1000000
SET LONGCHUNKSIZE 1000000
SET LINESIZE 1000
SET PAGESIZE 0
SET TRIM ON
SET TRIMSPOOL ON
SET ECHO OFF
SET FEEDBACK OFF

SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '<sql_id>', type => 'TEXT')
AS report FROM dual;

To get an overview what SQL commands are in V$SQL_MONITOR you can use:
SET LINESIZE 300
COLUMN sql_text FORMAT A100
SELECT sql_id, status, sql_text FROM v$sql_monitor;

or you can use the function  REPORT_SQL_MONITOR_LIST.
For the above example this shows that there is a statement with the sql id 526mvccm5nfy4.
We can get now a report with the following command:



       
       
SET LONG 1000000 SET FEEDBACK OFF SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id =>'526mvccm5nfy4',type=> 'TEXT') AS report FROM dual;
Global Information ------------------------------ Status : DONE (ALL ROWS) Instance ID : 1 Session : SCOTT (18:407) SQL ID : 526mvccm5nfy4 SQL Execution ID : 16777216 Execution Started : 11/24/2011 15:43:11 First Refresh Time : 11/24/2011 15:43:11 Last Refresh Time : 11/24/2011 15:43:12 Duration : 1s Module/Action : SQL*Plus/- Service : SYS$USERS Program : sqlplus.exe Fetch Calls : 4 Global Stats ===================================================================================== | Elapsed | Cpu | IO | PL/SQL | Other | Fetch | Buffer | Read | Read | | Time(s) | Time(s) | Waits(s) | Time(s) | Waits(s) | Calls | Gets | Reqs | Bytes | ===================================================================================== | 0.24 | 0.02 | 0.22 | 0.00 | 0.01 | 4 | 198 | 16 | 144KB | ===================================================================================== SQL Plan Monitoring Details (Plan Hash Value=1281390562) =================================================================================================================== | Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Read | | | | | (Estim) | | Active(s) | Active | | (Actual) | Reqs | =================================================================================================================== | 0 | SELECT STATEMENT | | | | 1 | +1 | 1 | 3 | | | 1 | SORT ORDER BY | | 4 | 8 | 1 | +1 | 1 | 3 | | | 2 | SORT GROUP BY | | 4 | 8 | 1 | +1 | 1 | 3 | | | 3 | MERGE JOIN | | 14 | 6 | 1 | +1 | 1 | 14 | | | 4 | TABLE ACCESS BY INDEX ROWID | DEPT | 4 | 2 | 1 | +1 | 1 | 4 | 1 | | 5 | INDEX FULL SCAN | PK_DEPT | 4 | 1 | 1 | +1 | 1 | 4 | 1 | | 6 | SORT JOIN | | 14 | 4 | 1 | +1 | 4 | 14 | | | 7 | TABLE ACCESS FULL | EMP | 14 | 3 | 1 | +1 | 1 | 14 | 2 | ===================================================================================================================

The active option is the best choice for parallel queries.
You can get this using the following:
spool monitor_sql.html
SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id =>'<sql_id>',type =>'active')
AS report FROM dual;
spool off

You will then need to open the spool file , remove the first lines before the first <html>.
Then you can open the file in a browser with an Internet connection to OTN.

REPORT_SQL_MONITOR_LIST

The REPORT_SQL_MONITOR_LIST function was added in Oracle 11g Release 2 to generate a summary of all SQL stored in V$SQL_MONITOR.

SET LONG 1000000
SET LONGCHUNKSIZE 1000000
SET LINESIZE 1000
SET PAGESIZE 0
SET TRIM ON
SET TRIMSPOOL ON
SET ECHO OFF
SET FEEDBACK OFF

SELECT DBMS_SQLTUNE.report_sql_monitor_list(type =>'TEXT',report_level => 'ALL') AS report FROM dual;




From:http://myoracleguide.com/msa/ID%201380492.1%20Monitoring%20SQL%20statements%20with%20Real-Time%20SQL%20Monitoring.htm




Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值