Check execution time and plan for SQL ID in Oracle

Check execution time and plan for SQL ID from the history table in Oracle

dba_hist_active_sess_history table is used to fetch the information about SQL id

set linesize 150
col exec_start for a25
col exec_end for a25
col difference for a28
select instance_number, sql_exec_id, sql_plan_hash_value, exec_start, to_char(exec_end,'MM/DD/YYYY HH:MI:SS AM') exec_end, difference
from (
select instance_number, sql_exec_id, sql_plan_hash_value, to_char(sql_exec_start,'MM/DD/YYYY HH:MI:SS AM') as exec_start, max(sample_time) exec_end,
EXTRACT(HOUR FROM (max(sample_time) - sql_exec_start) DAY TO SECOND) || ' HH '
|| EXTRACT(MINUTE FROM (max(sample_time) - sql_exec_start) DAY TO SECOND) || ' MI '
|| EXTRACT(SECOND FROM (max(sample_time) - sql_exec_start) DAY TO SECOND) || ' SS' difference
from dba_hist_active_sess_history
where sql_id='&sql_id'
group by instance_number, sql_exec_id, sql_plan_hash_value, sql_exec_start
order by sql_exec_start );

Related posts

How to deal with ORA-00020: maximum number of processes (%s) exceeded

How to resolve ORA-01111 ORA-01110 ORA-01157 in a physical standby database 

Công cụ tự động khai báo datafile – Oracle