DBA AWR SQL Explain Plan History

Description
Categories: DBA, Diagnostic Pack, Enginatics
Execution plan history for a particular SQL id from the automatic workload repository
select
dhsp.sql_id,
dhsp.plan_hash_value,
xxen_util.client_time(dhsp.timestamp) timestamp,
lpad(' ',dhsp.depth*2)||dhsp.operation||
case when dhsp.options is not null then ' '||dhsp.options end||
case when dhsp.object_name is not null then ' '||dhsp.object_type||' '||dhsp.object_owner||'.'||dhsp.object_name end operation,
dhsp.qblock_name query_block,
lpad(' ',dhsp.depth)||dhsp.depth depth,
dhsp.cardinality,
dhsp.bytes/1000000 mb,
dhsp.time,
dhsp.cost,
dhsp.cpu_cost,
dhsp.io_cost,
dhsp.id,
dhsp.parent_id,
ds.object_size
from
dba_hist_sql_plan dhsp,
(
select
ds.owner,
ds.segment_type,
ds.segment_name,
sum(ds.blocks)*(select vp.value from v$parameter vp where vp.name like 'db_block_size')/1000000 object_size
from
dba_segments ds
group by
ds.owner,
ds.segment_type,
ds.segment_name
) ds
where
1=1 and
dhsp.dbid=(select vd.dbid from v$database vd) and
dhsp.object_owner=ds.owner(+) and
case when dhsp.object_type like '% %' then substr(dhsp.object_type,1,instr(dhsp.object_type,' ')) else dhsp.object_type end=ds.segment_type(+) and
dhsp.object_name=ds.segment_name(+)
order by
dhsp.sql_id,
dhsp.timestamp desc,
dhsp.plan_hash_value,
dhsp.id,
dhsp.position
Parameter NameSQL textValidation
Using Index
(dhsp.sql_id,dhsp.plan_hash_value) in (select dhsp0.sql_id, dhsp0.plan_hash_value from dba_hist_sql_plan dhsp0 where dhsp0.object_name=:index_name and dhsp0.operation='INDEX')
LOV
Objects larger than x GB
ds.object_size/1000>:min_object_size_gb
Number
Options
dhsp.options like :options||'%'
LOV
Object Name
dhsp.object_name=:object_name
LOV
Plan Hash Value
dhsp.plan_hash_value=:plan_hash_value
LOV
SQL Id
dhsp.sql_id=:sql_id
LOV