0% found this document useful (0 votes)
10 views

SPM_SQL_PROFILE

The document discusses issues related to SQL plan baselines and SQL profiles in Oracle databases, specifically focusing on the reproducibility of SQL plan management (SPM) plans. It provides SQL queries to retrieve the plan hash value (phv2) of the execution plan generated by the Cost-Based Optimizer (CBO) and to obtain the plan ID of stored SPM plans. The key takeaway is that the CBO must generate a plan with a matching phv2 to utilize the stored SPM plan effectively.

Uploaded by

PGTEST
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

SPM_SQL_PROFILE

The document discusses issues related to SQL plan baselines and SQL profiles in Oracle databases, specifically focusing on the reproducibility of SQL plan management (SPM) plans. It provides SQL queries to retrieve the plan hash value (phv2) of the execution plan generated by the Cost-Based Optimizer (CBO) and to obtain the plan ID of stored SPM plans. The key takeaway is that the CBO must generate a plan with a matching phv2 to utilize the stored SPM plan effectively.

Uploaded by

PGTEST
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Question: SQL not picking up plan from sql baseline

https://community.oracle.com/thread/3695707

Question: SQLT SQL Profile not "Sticking", how do I eliminate inefficient Plan Hash Value?

https://community.oracle.com/thread/3683705

When it comes to SQL plan baseline you have to be careful about their reproducibility. The
reproducibility of the SPM plan by the CBO is possible only if the phv2 of the execution plan the CBO
came up with when hard parsing the query equals the planId of one of the stored SPM plan.

You can get the phv2 of your CBO plan using the following query
SELECT
p.sql_id
,p.plan_hash_value
,p.child_number
,t.phv2
FROM
v$sql_plan p
,xmltable('for $i in /other_xml/info
where $i/@type eq "plan_hash_2"
return $i'
passing xmltype(p.other_xml)
columns phv2 number path '/') t
WHERE p.sql_id = 'your_sql_id'
AND p.other_xml is not null;

And you can get the planId of your SPM plan using the following query:

select
a.plan_name
,b.plan_id
,a.enabled
,a.accepted
from
dba_sql_plan_baselines a
,sys.sqlobj$ b
where
a.signature = b.signature
and a.plan_name = b.name
and a.signature = <your_plan_signature>

You might also like