Oracle SQL Monitoring

All of us has some point in time used Oracle SQL monitoring reports which are pretty useful to identify critical statistics for an currently running query which can be find through various database queries as well.
With SQL monitoring reports it makes pretty easy for DBA's to identify real time statistics about qery execution state.

There are multiple ways where sql monitoring reports can be extracts


  1. Real Time - Fetch the reports when query is running.
  2. Historical Reports - Fetch the reports when queries are already completed in some point time in history.
Real Time Reports can be extracted through

  1. OEM (Oracle Enterprise Manager)
  2. SQLPLUS commands - We are going to discuss them within this blog.
Very often everyone of us might of noticed sql monitoring reports are not generated for all queries, which is due to some important factor:

_sqlmon_threshold with default value of 5 means any query which has combined CPU and I/O execution more than 5 seconds is entitled to have sql monitoring reports 

_sqlmon_max_planlines with default value of 300 means any query which has execution plan more than 300 lines will not be monitored through sql mon reports.


_sqlmon_max_plan limits the number of sql being  monitoered by sqlmon these are by default calculated as 20 * CPU_COUNT.

I don't advise you to set any of above parameters on system level, but it can be used on session level for testing purpose.

Historically SQL Monitoring reports were only kept in memory buffers but with later version of oracle these reports are being persisted on oracle disk with the retention based on your AWR.
Historical reports can be viewed through DBA_HIST_REPORTS.

Extract the report id from dba_hist_reports and generate the reports using package dba_auto_report.report_repository_detail and key1 would the sql id of your query.

select report_id from dba_hist_reports
where key1='yoursqlid';

Use the report_id from above query to extract the report:


SET echo ON
SET trimspool ON
SET TRIM ON
SET pages 0
SET linesize 4000
SET LONG 10000000
SET longchunksize 1000000
spool sqlmon_sql_id.html
 
SELECT dbms_auto_report.Report_repository_detail(rid=>report_id from query, TYPE=>'text')
FROM dual;
 
spool OFF
There are many other blogs which will give you information about generating read time sql monitoring reports through OEM and SQLPLUS, hence not covering them within this blog. Feel free to leave your comments!!!

Comments

Popular posts from this blog

How to Solve - "WAIT FOR EMON PROCESS NTFNS"

Query Regression - "OR" Transformation Oracle 19c

ORA - 12537: TNS: connection closed