<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Unstable Plans (Oracle Plan Stability/Instability)</title>
	<atom:link href="http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/feed/" rel="self" type="application/rss+xml" />
	<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/</link>
	<description>Just another Oracle blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 21:28:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: performance tuning</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-76279</link>
		<dc:creator>performance tuning</dc:creator>
		<pubDate>Sat, 10 Dec 2011 06:55:37 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-76279</guid>
		<description>&lt;strong&gt;performance tuning...&lt;/strong&gt;

[...]Kerry Osborne&#8217;s Oracle Blog &#187; Blog Archive &#187; Unstable Plans (Oracle Plan Stability/Instability) &#8211; Kerry Osborne’s Oracle Blog[...]...</description>
		<content:encoded><![CDATA[<p><strong>performance tuning&#8230;</strong></p>
<p>[...]Kerry Osborne&#8217;s Oracle Blog &raquo; Blog Archive &raquo; Unstable Plans (Oracle Plan Stability/Instability) &#8211; Kerry Osborne’s Oracle Blog[...]&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-75356</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Mon, 05 Dec 2011 05:36:54 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-75356</guid>
		<description>&lt;strong&gt;Peter...&lt;/strong&gt;

[...]Kerry Osborne&#8217;s Oracle Blog &#187; Blog Archive &#187; Unstable Plans (Oracle Plan Stability/Instability) &#8211; Kerry Osborne’s Oracle Blog[...]...</description>
		<content:encoded><![CDATA[<p><strong>Peter&#8230;</strong></p>
<p>[...]Kerry Osborne&#8217;s Oracle Blog &raquo; Blog Archive &raquo; Unstable Plans (Oracle Plan Stability/Instability) &#8211; Kerry Osborne’s Oracle Blog[...]&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-45164</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Thu, 16 Jun 2011 18:27:06 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-45164</guid>
		<description>Antony,

That&#039;s more difficult but do-able. You&#039;d have to change the group by to use some portion of the sql_text (that presumably matches). I have a rough script that does something like that based on matching the first 80 characters of the SQL text. It is very rough but should give you an idea of how to go about what you are after. Unfortunately I don&#039;t have time right now to work on this, but you can try this as a starting point: 

&lt;pre&gt;
-- unstable_plans_by_sqltext.sql
set lines 155
col execs for 999,999,999
col min_etime for 999,999.99
col max_etime for 999,999.99
col avg_etime for 999,999.999
col sql_text for a80
break on sql_text skip 1
select a.sql_id,
substr(dbms_lob.substr(sql_text,3999,1),1,80) sql_text, b.execs, min_etime, max_etime, norm_stddev
from dba_hist_sqltext a, (
select sql_id, sum(execs) execs, min(avg_etime) min_etime, max(avg_etime) max_etime, stddev_etime/min(avg_etime) norm_stddev
from (
select sql_id, plan_hash_value, execs, avg_etime,
stddev(avg_etime) over (partition by sql_id) stddev_etime
from (
select sql_id, plan_hash_value,
sum(nvl(executions_delta,0)) execs,
(sum(elapsed_time_delta)/decode(sum(nvl(executions_delta,0)),0,1,sum(executions_delta))/1000000) avg_etime
-- sum((buffer_gets_delta/decode(nvl(buffer_gets_delta,0),0,1,executions_delta))) avg_lio
from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
where ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta &gt; 0
and elapsed_time_delta &gt; 0
group by sql_id, plan_hash_value
)
)
group by sql_id, stddev_etime
) b
where norm_stddev &gt; nvl(to_number(&#039;&amp;min_stddev&#039;),2)
and max_etime &gt; nvl(to_number(&#039;&amp;min_etime&#039;),.1)
and substr(dbms_lob.substr(sql_text,3999,1),1,80) like nvl(&#039;&amp;sql_text&#039;,substr(dbms_lob.substr(sql_text,3999,1),1,80))
and a.sql_id = b.sql_id
order by 2
/
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Antony,</p>
<p>That&#8217;s more difficult but do-able. You&#8217;d have to change the group by to use some portion of the sql_text (that presumably matches). I have a rough script that does something like that based on matching the first 80 characters of the SQL text. It is very rough but should give you an idea of how to go about what you are after. Unfortunately I don&#8217;t have time right now to work on this, but you can try this as a starting point: </p>
<pre>
-- unstable_plans_by_sqltext.sql
set lines 155
col execs for 999,999,999
col min_etime for 999,999.99
col max_etime for 999,999.99
col avg_etime for 999,999.999
col sql_text for a80
break on sql_text skip 1
select a.sql_id,
substr(dbms_lob.substr(sql_text,3999,1),1,80) sql_text, b.execs, min_etime, max_etime, norm_stddev
from dba_hist_sqltext a, (
select sql_id, sum(execs) execs, min(avg_etime) min_etime, max(avg_etime) max_etime, stddev_etime/min(avg_etime) norm_stddev
from (
select sql_id, plan_hash_value, execs, avg_etime,
stddev(avg_etime) over (partition by sql_id) stddev_etime
from (
select sql_id, plan_hash_value,
sum(nvl(executions_delta,0)) execs,
(sum(elapsed_time_delta)/decode(sum(nvl(executions_delta,0)),0,1,sum(executions_delta))/1000000) avg_etime
-- sum((buffer_gets_delta/decode(nvl(buffer_gets_delta,0),0,1,executions_delta))) avg_lio
from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
where ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta > 0
and elapsed_time_delta > 0
group by sql_id, plan_hash_value
)
)
group by sql_id, stddev_etime
) b
where norm_stddev > nvl(to_number('&#038;min_stddev'),2)
and max_etime > nvl(to_number('&#038;min_etime'),.1)
and substr(dbms_lob.substr(sql_text,3999,1),1,80) like nvl('&#038;sql_text',substr(dbms_lob.substr(sql_text,3999,1),1,80))
and a.sql_id = b.sql_id
order by 2
/
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: antony</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-45106</link>
		<dc:creator>antony</dc:creator>
		<pubDate>Wed, 15 Jun 2011 14:58:35 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-45106</guid>
		<description>How about applications which use bind variables quite a lot where you&#039;ll not get the same SQLID.For an example,in PeopleSoft applications every job is driven by a process instance which is a bind variable.So you will not get the same SQLID for every run of the same job.How do I find unstable plans in those cases using your analytic function approach?

Thanks</description>
		<content:encoded><![CDATA[<p>How about applications which use bind variables quite a lot where you&#8217;ll not get the same SQLID.For an example,in PeopleSoft applications every job is driven by a process instance which is a bind variable.So you will not get the same SQLID for every run of the same job.How do I find unstable plans in those cases using your analytic function approach?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-41808</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Mon, 18 Apr 2011 18:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-41808</guid>
		<description>Ah - interesting. Thanks for following up on that Raja. I had not run into this issue before. 

Just to provide a little more info to casual observers, here&#039;s a bit of the MOS bug report:

RELEASE NOTES:
]]You may see a different plan hash value after every compilation of a SQL stat
]]ement even when the execution plan is the same when it involves cursor tempor
]]ary tables (name predixed by SYS_TEMP).
REDISCOVERY INFORMATION:
If you see a different plan hash value after every compilation of a SQL
statement even when the execution plan is the same and the plan involves
cursor temporary tables (name predixed by SYS_TEMP) then you are likely
to have encountered the same problem.
WORKAROUND:
None

It&#039;s supposed to be fixed in version 12.1 by the way. ;)</description>
		<content:encoded><![CDATA[<p>Ah &#8211; interesting. Thanks for following up on that Raja. I had not run into this issue before. </p>
<p>Just to provide a little more info to casual observers, here&#8217;s a bit of the MOS bug report:</p>
<p>RELEASE NOTES:<br />
]]You may see a different plan hash value after every compilation of a SQL stat<br />
]]ement even when the execution plan is the same when it involves cursor tempor<br />
]]ary tables (name predixed by SYS_TEMP).<br />
REDISCOVERY INFORMATION:<br />
If you see a different plan hash value after every compilation of a SQL<br />
statement even when the execution plan is the same and the plan involves<br />
cursor temporary tables (name predixed by SYS_TEMP) then you are likely<br />
to have encountered the same problem.<br />
WORKAROUND:<br />
None</p>
<p>It&#8217;s supposed to be fixed in version 12.1 by the way. ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raja</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-41779</link>
		<dc:creator>Raja</dc:creator>
		<pubDate>Mon, 18 Apr 2011 00:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-41779</guid>
		<description>I came to know it&#039;s a bug in 10.2.0.4. It&#039;s bug 10162430 caused same plan with multiple PHVs.</description>
		<content:encoded><![CDATA[<p>I came to know it&#8217;s a bug in 10.2.0.4. It&#8217;s bug 10162430 caused same plan with multiple PHVs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-40990</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Sat, 09 Apr 2011 14:04:23 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-40990</guid>
		<description>Hmmm, are you sure the plans are exactly the same? How are you comparing the plans? You could write a little script to compute your own hash value on all the data for the sql_id and child of interest in v$sql_plan and see if it comes up with the same value for both. I suspect there is something different (maybe it&#039;s not displayed in the xplan output though). I do not know exactly what is included in the the plan_hash_value calculation by the way. There may be other things besides what&#039;s exposed in the v$sql_plan.</description>
		<content:encoded><![CDATA[<p>Hmmm, are you sure the plans are exactly the same? How are you comparing the plans? You could write a little script to compute your own hash value on all the data for the sql_id and child of interest in v$sql_plan and see if it comes up with the same value for both. I suspect there is something different (maybe it&#8217;s not displayed in the xplan output though). I do not know exactly what is included in the the plan_hash_value calculation by the way. There may be other things besides what&#8217;s exposed in the v$sql_plan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raja</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-40828</link>
		<dc:creator>Raja</dc:creator>
		<pubDate>Thu, 07 Apr 2011 19:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-40828</guid>
		<description>I noticed two plan_hash_value for a SQL_ID with same execution plan. I thought plan_hash_value cannot be identical. Please let me know if I am wrong. how can there be two plan_hash_value for the same execution plan?I only bind_mismatch Y, but plan_hash_value is different, It on a 10.2.0.4 database using cursor_sharing set to exact.</description>
		<content:encoded><![CDATA[<p>I noticed two plan_hash_value for a SQL_ID with same execution plan. I thought plan_hash_value cannot be identical. Please let me know if I am wrong. how can there be two plan_hash_value for the same execution plan?I only bind_mismatch Y, but plan_hash_value is different, It on a 10.2.0.4 database using cursor_sharing set to exact.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Plan stability through Upgrade to 11G- Building a test case &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-35398</link>
		<dc:creator>Plan stability through Upgrade to 11G- Building a test case &#171; Coskan&#8217;s Approach to Oracle</dc:creator>
		<pubDate>Tue, 01 Feb 2011 11:01:34 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-35398</guid>
		<description>[...] References Used: http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/ http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/ [...]</description>
		<content:encoded><![CDATA[<p>[...] References Used: <a href="http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/" rel="nofollow">http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/</a> <a href="http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/" rel="nofollow">http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2008/10/unstable-plans/#comment-15485</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Mon, 19 Jul 2010 00:17:06 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=155#comment-15485</guid>
		<description>I think you are confusing plan_hash_value with hash_value (and old_hash_value). A statement can have only one sql_id and only one hash_value (its based on the text of the statement). A statement can have many plan_hash_values. And yes you can influence a statement to use a particular plan. I&#039;ve done a number of posts on using SQL Profiles to do just that. See &lt;a href=&quot;http://kerryosborne.oracle-guy.com/2009/04/oracle-sql-profiles/&quot; rel=&quot;nofollow&quot;&gt;SQL Profiles&lt;/a&gt; for example.

Kerry</description>
		<content:encoded><![CDATA[<p>I think you are confusing plan_hash_value with hash_value (and old_hash_value). A statement can have only one sql_id and only one hash_value (its based on the text of the statement). A statement can have many plan_hash_values. And yes you can influence a statement to use a particular plan. I&#8217;ve done a number of posts on using SQL Profiles to do just that. See <a href="http://kerryosborne.oracle-guy.com/2009/04/oracle-sql-profiles/" rel="nofollow">SQL Profiles</a> for example.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
</channel>
</rss>

