Script to See Historical data for any SQL ID

column plan_hash_value format 999999999999999

SELECT sql_id,
snap_id,
plan_hash_value,
SUM(disk_reads_total) disk_reads_total,
SUM(executions_total) total_executions,
SUM(elapsed_time_total) / ( 1000 * 1000 ) elapstime_Total,
SUM(rows_processed_total) total_rows_processed
FROM dba_hist_sqlstat
WHERE sql_id = ‘&sql_id’
GROUP BY sql_id,
snap_id,
plan_hash_value
ORDER BY snap_id;

I personally use this script to check if SQL plan has changed for any sql id in recent past.

Leave a comment

Your email address will not be published. Required fields are marked *