
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display SQL Execution Progress with Execution Plan in Oracle
Problem:
You want to view where Oracle SQL is taking time within a SQL execution plan.
Solution
With Oracle 11g version, we can view SQL execution plan progress while the SQL is running. The “V$SQL_PLAN_MONITOR” view contains a row for each step of a SQL statement’s execution plan. Below SQL will help to view the execution plan along with the progress.
The “V$SQL_PLAN_MONITOR" provides you with information on the steps that are using the most resources. The statistics in "V$SQL_PLAN_MONITOR” are updated every second.
We can also generate a real time text, HTML, or even a XML report of query progress within an execution plan by using the REPORT_SQL_MONITOR function of the DBMS_SQLTUNE package.
Example
select a.sid ,a.status ,to_char(a.sql_exec_start,'yymmdd hh24:mi') start_time ,a.plan_line_id ,a.plan_operation ,a.plan_options ,a.output_rows ,a.workarea_mem mem_bytes ,a.workarea_tempseg temp_bytes from v$sql_plan_monitor a ,v$sql_monitor b where a.status NOT LIKE '%DONE%' and a.key = b.key order by a.sid, a.sql_exec_start, a.plan_line_id;
To generate a HTML report.
Example
SET LINES 3000 PAGES 0 LONG 1000000 TRIMSPOOL ON SPOOL report.html select dbms_sqltune.report_sql_monitor(session_id=> 901, event_detail => 'YES' ,report_level => 'ALL' ,type => 'HTML' ) from dual; SPOOL OFF;