Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Lalith.

Asked: November 14, 2016 - 7:40 pm UTC

Last updated: November 15, 2016 - 1:19 am UTC

Version: 11.2.0.3

Viewed 1000+ times

You Asked

Hi Tom,

Is there a way to find cpu_time, db_time, physical_read_requests, physical_write_requests...etc per execution basis ?
Say I run a particular SQL multiple times with different bind values.
I'm interested in seeing sql with bind variables substitued and timing values and wait events for each of those executions.

I would like to see this on
a. current
b. historical basis

I tried following. But it gives aggregate for all the executions :

select ss.sql_id, to_char(sn.begin_interval_time,'YYYYMMDD:HH24MISS'),
ss.parsing_schema_name schema_name,
round(ss.elapsed_time_delta/1000000,2) elapsed_time_delta_sec,
round(ss.cpu_time_delta/1000000,2) cpu_time_delta_sec,
round(ss.iowait_delta/1000000,2) iowait_delta_sec,
executions_delta,
PHYSICAL_READ_REQUESTS_DELTA read_req,
PHYSICAL_WRITE_REQUESTS_DELTA write_req
from dba_hist_snapshot sn, dba_hist_sqlstat ss
where sn.snap_id = ss.snap_id
and sn.begin_interval_time > sysdate - 5/24
order by 1,2
;

and Connor said...

The only way to do this with true accuracy would be with a trace,ie,

dbms_monitor.session_trace_enable(waits=>true,binds=>true)

A reasonable approximation might be to use ASH (active session history) and/or more frequent AWR snapshots.


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.