Monitoring SQL Statements with Real-Time SQL Monitoring (文档 ID 1380492.1)
2017-11-20 19:41
465 查看
In this Document
Oracle Database - Enterprise Edition - Version 11.1.0.6 and later
Information in this document applies to any platform.
The Document explains how to use Real-Time SQL Monitoring to monitor queries.
For developers and DBA's
The Oracle 11g Database or later versions 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. The MONITOR hint can also be used to turn on SQL Monitoring for a SQL statement.
SQL Monitoring requires:
A Diagnostics and Tuning Pack License
STATISTICS_LEVEL parameter to be set to 'TYPICAL' or 'ALL'
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.
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:
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
spool monitor_sql.html
SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id =>''0tqfh0cggfg0v',type=> 'HTML')
AS report FROM dual;
spool off
The options are TEXT, HTML or ACTIVE. The active option is the best choice for parallel queries.
The output looks like this :
HTML:
TEXT:
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;
Purpose |
Scope |
Details |
DBMS_SQLTUNE.REPORT_SQL_MONITOR |
REPORT_SQL_MONITOR_LIST |
APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.1.0.6 and laterInformation in this document applies to any platform.
PURPOSE
The Document explains how to use Real-Time SQL Monitoring to monitor queries.
SCOPE
For developers and DBA's
DETAILS
The Oracle 11g Database or later versions has a new interface to monitor long running SQL commands.The feature is called Real-Time SQL Monitoring. By default, SQL monitoring is automatically startedwhen 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. The MONITOR hint can also be used to turn on SQL Monitoring for a SQL statement.
SQL Monitoring requires:
A Diagnostics and Tuning Pack License
STATISTICS_LEVEL parameter to be set to 'TYPICAL' or 'ALL'
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
spool monitor_sql.html
SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id =>''0tqfh0cggfg0v',type=> 'HTML')
AS report FROM dual;
spool off
The options are TEXT, HTML or ACTIVE. The active option is the best choice for parallel queries.
The output looks like this :
HTML:
TEXT:
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;
相关文章推荐
- ID 1380492.1 Monitoring SQL statements with Real-Time SQL Monitoring
- 【SQL Performance】实时SQL监控功能(Real-Time SQL Monitoring)
- Real-Time SQL Monitoring
- Real-Time SQL Monitoring using DBMS_SQLTUNE (REPORT_SQL_MONITOR, REPORT_SQL_MONITOR_LIST and REPORT_
- oracle11g Real Time SQL Monitoring
- Monitoring the Cluster in Real Time with CHM (Cluster Health Monitor)
- Real-Time SQL Monitoring using DBMS_SQLTUNE
- Real-Time SQL Monitoring using DBMS_SQLTUNE
- oratop - Utility for Near Real-time Monitoring of Databases, RAC and Single Instance (Doc ID 1500864
- Real Time Interactive IP LAN Monitoring with IPTraf Tool
- work Realtime Asterisk with MySQL.
- sql优化实战:排序字段——到底是time还是ID
- Real-Time Graphing With Graphite
- Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks程序(Python)配置问题总结
- Database realtime monitoring
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server. (文档 ID 885522.1)
- java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
- 11i - 12 Gather Schema Statistics fails with Ora-20001 errors after 11G database Upgrade (文档 ID 781813.1)
- 11.2 Job Seperation causes WARNINGS and ORA-15025 ORA-27041 With Certain Users (文档 ID 1317692.1)
- Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks(更快的RCNN:通过区域提议网络实现实时)