Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

  report_sql_monitor tips

Oracle Database Tips by Donald BurlesonApril 4, 2015

Question:  How do I use the report_sql_monitor function?  Also can you give an example of using dbms_sqltune.report_sql_monior in action?
 
Answer:  The report_sql_monitor function is used to displays a report based upon the real time SQL monitoring data being captured. It returns that report as a CLOB.  These are the report_sql_monitor parameters:

ARGUMENT

TYPE

IN / OUT

DEFAULT VALUE

SQL_ID

VARCHAR2

IN

NULL

SESSION_ID

NUMBER

IN

NULL

SESSION_SERIAL

NUMBER

IN

NULL

SQL_EXEC_START

DATE

IN

NULL

SQL_EXEC_ID

NUMBER

IN

NULL

INST_ID

NUMBER

IN

-1

START_TIME_FILTER

DATE

IN

NULL

END_TIME_FILTER

DATE

IN

NULL

INSTANCE_ID_FILTER

NUMBER

IN

NULL

PARALLEL_FILTER

VARCHAR2

IN

NULL

EVENT_DETAIL

VARCHAR2

IN

'YES'

REPORT_LEVEL

VARCHAR2

IN

'TYPICAL'

TYPE

VARCHAR2

IN

'TEXT'

Report_sql_monitor Parameters

 
 The report_sql_monitor function begins by using the monitor hint in SQL to monitor the SQL statement:

select /*+ monitor */
   stuff
from
   mytab . . .

Next, you need to gather the sql_id of the statements:

col c1 heading 'SQL|ID' format a13

col c2 heading 'Cost' format 9,999,999

col c3 heading 'SQL Text' format a200

select

p.sql_id            c1,

p.cost              c2,

to_char(s.sql_text) c3

from

dba_hist_sql_plan   p,

dba_hist_sqltext    s

where

p.id = 0

and

p.sql_id = s.sql_id

and

p.cost is not null

order by

p.cost desc

;

The output of the above query might look like this, showing the high cost SQL statements over time:

SQL

ID Cost SQL Text

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

847ahztscj4xw 358,456    select /*+ monitor */

                             s.begin_interval_time c1,

                             pl.sql_id c2,

                             pl.object_name c3,
                             . . .

Now that we have the SQL_ID we can use the report_sql_monitor function to display details about the SQL statements:


set long 1000000
set longchunksize 1000000
set lines 1000
set pages 80
set trim on
set trimspool on
set echo off
set feedback off
 
spool /tmp/report_sql_monitor.htm

select
   dbms_sqltune.report_sql_monitor(

     sql_id       => '847ahztscj4xw',
     type         => 'html',
     report_level => 'all') as report
from
   dual;

spool off

This will produce the SQL monitoring report, including execution statistics and the execution plan for the SQL statement that is being monitored.  In many cases it is easier to use the SQL*Plus Autotrace command than to use the report_sql_monitor function.

   
Oracle Training from Don Burleson 

The best on site "Oracle training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!

Oracle training
 
 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster