I`m trying to obtain the total time of a query execution
I have this query but not allways get the output that I hope, For example for the same parallel 4 execution of a query sometimes I obtain 5 rows (query controller and 4 parallels) but other times I only obtain 2 parallel process result (the parallels processes only open in the same instance)
Is this query correct or I need to add something more?
select inst_id, sql_exec_id,session_id, QC_SESSION_ID,program,sql_id,sql_plan_hash_value,round((count(*))/60/60, 2) as Horas
from gv$active_session_history ash
where sql_id='7u0wv0g5r3y2n'
and sql_exec_id is not null
group by inst_id, sql_exec_id,session_id,QC_SESSION_ID,program,sql_id,sql_plan_hash_value
order by 2,1,4,5 desc;
Best Answer
I use set events 10046, for the explain plan and 10053 for the waits. Once you run the queries that you want timings for, assuming that you are using 10g/11g/12c go to the diag trace folder, find your trace files and run tkprof against the trace files.
This will give really good information about how the queries ran, how long, how much logical/physical IO, explain plan and waits. Plus you don't need any optional components to get the information.