Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Start and End time of a sql_query executed b/w a particular time range

916413Jul 11 2012 — edited Jul 12 2012
Hi,

I m trying to develop a sql query that would give me the start and end time of a sql_query executed b/w a particular time range .
Can anyone please validate if below query is correct ?

select min(s.begin_interval_time)"Start_Time",max(s.end_interval_time)"End_Time",
sum(sql.EXECUTIONS_TOTAL)"Total_Executions",
sum(sql.CPU_TIME_TOTAL)/100000000 "Total_CPU_Time(Min)",
sum(sql.ELAPSED_TIME_TOTAL)/100000000 "Total_Execution_Time(Min)"
from dba_hist_snapshot s, dba_hist_sqlstat sql
where s.snap_id = sql.snap_id 
and sql.sql_id ='3a6yhqx9u671w'
and  s.begin_interval_time > to_timestamp('2012-07-10 03:00:00 PM', 'yyyy-mm-dd HH:MI:SS PM') 
and s.end_interval_time < to_timestamp('2012-07-11 09:00:00 AM', 'yyyy-mm-dd HH:MI:SS AM');

Start_Time                     End_Time                       Total_Executions Total_CPU_Time(Min) Total_Execution_Time(Min)
------------------------------ ------------------------------ ---------------- ------------------- -------------------------
10-JUL-12 04.00.11.170 PM      11-JUL-12 02.45.48.432 AM                   549          360.443955                18788.4383
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2012
Added on Jul 11 2012
7 comments
887 views