<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Debugging</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 19 Jun 2013 16:07:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Todor Botev</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-49346</link>
		<dc:creator><![CDATA[Todor Botev]]></dc:creator>
		<pubDate>Thu, 23 Aug 2012 08:18:23 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-49346</guid>
		<description><![CDATA[&quot;The most critical piece of advice I had given them (after listening very carefully to their description of the system) was to get rid of ALL the histograms they had on their system, and then watch very carefully for any signs that they might need to re-introduce a handful of histograms over the next few weeks.&quot;

I too find this to be the correct strategy for applying histograms to a system - start with none and look whether there are system parts that need some. Is it a general approach you advise your customers? Or was there any specific bit of information (e.g. using literals in the predicates) that made you think this would make the system perform better?]]></description>
		<content:encoded><![CDATA[<p>&#8220;The most critical piece of advice I had given them (after listening very carefully to their description of the system) was to get rid of ALL the histograms they had on their system, and then watch very carefully for any signs that they might need to re-introduce a handful of histograms over the next few weeks.&#8221;</p>
<p>I too find this to be the correct strategy for applying histograms to a system &#8211; start with none and look whether there are system parts that need some. Is it a general approach you advise your customers? Or was there any specific bit of information (e.g. using literals in the predicates) that made you think this would make the system perform better?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-49143</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sun, 19 Aug 2012 16:16:18 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-49143</guid>
		<description><![CDATA[Andrea,

I am a little surprised by your comment that:  &lt;i&gt;&quot;Oracle never adds any additional cost for user-defined PL/SQL functions&quot;&lt;/i&gt;, since my example seems to show quite clearly that Oracle has added a cost in this case. 

Do you have a simple demonstration that I can use to recreate your observation - and have you tested it on the latest version of Oracle ?

Looking through my notes I find that I haven&#039;t done anything with &quot;associate statistics&quot; since 2006, so I&#039;m not in a position to make any comments about what that might do, and I haven&#039;t come across but 12332294 before. You question did make me wonder, though, whether your comment about &quot;no cost&quot; applied to operators rather than functions.]]></description>
		<content:encoded><![CDATA[<p>Andrea,</p>
<p>I am a little surprised by your comment that:  <i>&#8220;Oracle never adds any additional cost for user-defined PL/SQL functions&#8221;</i>, since my example seems to show quite clearly that Oracle has added a cost in this case. </p>
<p>Do you have a simple demonstration that I can use to recreate your observation &#8211; and have you tested it on the latest version of Oracle ?</p>
<p>Looking through my notes I find that I haven&#8217;t done anything with &#8220;associate statistics&#8221; since 2006, so I&#8217;m not in a position to make any comments about what that might do, and I haven&#8217;t come across but 12332294 before. You question did make me wonder, though, whether your comment about &#8220;no cost&#8221; applied to operators rather than functions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-49142</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sun, 19 Aug 2012 16:09:02 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-49142</guid>
		<description><![CDATA[Todor,

Sorry about the delay answering - I&#039;ve done 3 US, two conferences, and two seminars in the week.
The core of the change occurred in 10g with cost-based query transformation.]]></description>
		<content:encoded><![CDATA[<p>Todor,</p>
<p>Sorry about the delay answering &#8211; I&#8217;ve done 3 US, two conferences, and two seminars in the week.<br />
The core of the change occurred in 10g with cost-based query transformation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Delete Column Histograms to Improve SQL Plan Stability &#187; Eddie Awad&#039;s Blog</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-49011</link>
		<dc:creator><![CDATA[Delete Column Histograms to Improve SQL Plan Stability &#187; Eddie Awad&#039;s Blog]]></dc:creator>
		<pubDate>Mon, 13 Aug 2012 21:02:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-49011</guid>
		<description><![CDATA[[...] noting that Jonathan Lewis was very successful in tuning a customer&#8217;s query by simply deleting histograms:  The most [...]]]></description>
		<content:encoded><![CDATA[<p>[...] noting that Jonathan Lewis was very successful in tuning a customer&#8217;s query by simply deleting histograms:  The most [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Monti</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-48982</link>
		<dc:creator><![CDATA[Andrea Monti]]></dc:creator>
		<pubDate>Mon, 13 Aug 2012 10:22:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-48982</guid>
		<description><![CDATA[You say &quot;I think that Oracle has applied the 5% subquery factor to the number of rows in the index before applying the cost of calling the function, and then it hasn’t added ANY cost to the full scan to allow for the number of times that it will have to call the subquery. &quot;

I have found that Oracle never adds any additional cost for user-defined PL/SQL functions and this can lead to really sub-optimal plans because a condition like &quot;myfunction( mColumn ) = 0&quot; always has a default selectivity of 5% and an additional cost of 0, even if it involves complex subqueries .
Did you try to use ASSOCIATE STATISTICS to inform the CBO of the true cost of the function, or do you think that bugs like 12332294 make the &quot;ASSOCIATE STATISTICS &quot; command useless?
	
Regards,
Andrea]]></description>
		<content:encoded><![CDATA[<p>You say &#8220;I think that Oracle has applied the 5% subquery factor to the number of rows in the index before applying the cost of calling the function, and then it hasn’t added ANY cost to the full scan to allow for the number of times that it will have to call the subquery. &#8221;</p>
<p>I have found that Oracle never adds any additional cost for user-defined PL/SQL functions and this can lead to really sub-optimal plans because a condition like &#8220;myfunction( mColumn ) = 0&#8243; always has a default selectivity of 5% and an additional cost of 0, even if it involves complex subqueries .<br />
Did you try to use ASSOCIATE STATISTICS to inform the CBO of the true cost of the function, or do you think that bugs like 12332294 make the &#8220;ASSOCIATE STATISTICS &#8221; command useless?</p>
<p>Regards,<br />
Andrea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todor Botev</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-48946</link>
		<dc:creator><![CDATA[Todor Botev]]></dc:creator>
		<pubDate>Sun, 12 Aug 2012 06:44:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-48946</guid>
		<description><![CDATA[&quot;Historically the optimizer always used to leave subqueries to the last possible moment in an execution plan&quot;

Did this change with Oracle 11 ?]]></description>
		<content:encoded><![CDATA[<p>&#8220;Historically the optimizer always used to leave subqueries to the last possible moment in an execution plan&#8221;</p>
<p>Did this change with Oracle 11 ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-48879</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 10 Aug 2012 11:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-48879</guid>
		<description><![CDATA[Mohamed,

Thanks for the compliment.

Your comment is very useful - it&#039;s very easy to overlook a critical detail when trying to work out why an execution plan is so bad and your suggestion that &quot;index full scan&quot; and a missing &quot;sort order by&quot; is an excellent candidate for being on a &quot;quick check&quot; list before you start doing anything complex to analyze the problem. It&#039;s also an important indication of how important it is to get a current execution plan from memory rather than relying on &quot;explain plan&quot;.

Part of the analysis I haven&#039;t shown is the &quot;Outline&quot; content for this plan. This would show any local settings for optimizer parameters as opt_param() hints, but also show things like optimizer_features_enable() and (most importantly from your perspective) any hints like first_rows(1).]]></description>
		<content:encoded><![CDATA[<p>Mohamed,</p>
<p>Thanks for the compliment.</p>
<p>Your comment is very useful &#8211; it&#8217;s very easy to overlook a critical detail when trying to work out why an execution plan is so bad and your suggestion that &#8220;index full scan&#8221; and a missing &#8220;sort order by&#8221; is an excellent candidate for being on a &#8220;quick check&#8221; list before you start doing anything complex to analyze the problem. It&#8217;s also an important indication of how important it is to get a current execution plan from memory rather than relying on &#8220;explain plan&#8221;.</p>
<p>Part of the analysis I haven&#8217;t shown is the &#8220;Outline&#8221; content for this plan. This would show any local settings for optimizer parameters as opt_param() hints, but also show things like optimizer_features_enable() and (most importantly from your perspective) any hints like first_rows(1).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hourim</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-48876</link>
		<dc:creator><![CDATA[hourim]]></dc:creator>
		<pubDate>Fri, 10 Aug 2012 07:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-48876</guid>
		<description><![CDATA[Simply: thanks a lot for this elegant and structured strategy for solving a performance problem.

Just one supplementary question: when I see the presence of INDEX FULL SCAN coupled with the absence of a SORT OPRDER BY operation (while the query contains an ORDER BY) I immediately think about the optimizer being in a FIRST_ROWS mode. Although I don’t see in the query what could make the CBO jumping to a FIRST_ROWS mode, have you investigated this option before?]]></description>
		<content:encoded><![CDATA[<p>Simply: thanks a lot for this elegant and structured strategy for solving a performance problem.</p>
<p>Just one supplementary question: when I see the presence of INDEX FULL SCAN coupled with the absence of a SORT OPRDER BY operation (while the query contains an ORDER BY) I immediately think about the optimizer being in a FIRST_ROWS mode. Although I don’t see in the query what could make the CBO jumping to a FIRST_ROWS mode, have you investigated this option before?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-48868</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 09 Aug 2012 22:03:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-48868</guid>
		<description><![CDATA[Niall,

That would have been tough.
I think in this particular case, and with this particular hint, there&#039;s a fairly good chance we would have been safe. The /*+ no_push_subq */ hint falls into the class that I call &quot;strategic&quot; hints - it&#039;s not what I call micro-management, and that tends to make it a safer hint to use in these circumstances. (I&#039;d be very unhappy about using a hint like &quot;index(tableX, indexY)&quot; because of the high probability that Oracle would use different join orders in different uses of the view - then use the index as directed with catastrophic results.)

Historically the optimizer always used to leave subqueries to the last possible moment in an execution plan, so giving it an explicit hint to do so is something was fairly likely to recreate the pre-upgrade execution plan, and fairly likely to do &quot;not much&quot; damage if it wasn&#039;t the ideal solution in every case.

You&#039;re right to raise the point though. 

In this case we could have been in serious trouble if dropping the histograms hadn&#039;t worked. If the application had been using bind variables in all the appropriate places we could have generated an SQL Plan baseline for this query - but it was using literals, and there&#039;s no way (at present) to &quot;force match&quot; a baseline to a query in the way that you can with profiles. (Possibly we could have used Kerry&#039;s mechanism for cheating and forcing a complete sets of hints into the system as a &quot;force match&quot; profile - but I wouldn&#039;t want to do that on a production system). 

We could have investigated the effect of setting the optimizer_mode back to the earlier version to see how many things got fixed and how many new things broke. We might have tried running with cursor_sharing = force so that we could use attach an SQL Plan baseline to the query with bind variable substitution.

We might simply have got lucky and found that this particular view had been created for this particular piece of front-end code - but we would certainly have had to search the entire applicatin for every references to the view and tested for side effects.]]></description>
		<content:encoded><![CDATA[<p>Niall,</p>
<p>That would have been tough.<br />
I think in this particular case, and with this particular hint, there&#8217;s a fairly good chance we would have been safe. The /*+ no_push_subq */ hint falls into the class that I call &#8220;strategic&#8221; hints &#8211; it&#8217;s not what I call micro-management, and that tends to make it a safer hint to use in these circumstances. (I&#8217;d be very unhappy about using a hint like &#8220;index(tableX, indexY)&#8221; because of the high probability that Oracle would use different join orders in different uses of the view &#8211; then use the index as directed with catastrophic results.)</p>
<p>Historically the optimizer always used to leave subqueries to the last possible moment in an execution plan, so giving it an explicit hint to do so is something was fairly likely to recreate the pre-upgrade execution plan, and fairly likely to do &#8220;not much&#8221; damage if it wasn&#8217;t the ideal solution in every case.</p>
<p>You&#8217;re right to raise the point though. </p>
<p>In this case we could have been in serious trouble if dropping the histograms hadn&#8217;t worked. If the application had been using bind variables in all the appropriate places we could have generated an SQL Plan baseline for this query &#8211; but it was using literals, and there&#8217;s no way (at present) to &#8220;force match&#8221; a baseline to a query in the way that you can with profiles. (Possibly we could have used Kerry&#8217;s mechanism for cheating and forcing a complete sets of hints into the system as a &#8220;force match&#8221; profile &#8211; but I wouldn&#8217;t want to do that on a production system). </p>
<p>We could have investigated the effect of setting the optimizer_mode back to the earlier version to see how many things got fixed and how many new things broke. We might have tried running with cursor_sharing = force so that we could use attach an SQL Plan baseline to the query with bind variable substitution.</p>
<p>We might simply have got lucky and found that this particular view had been created for this particular piece of front-end code &#8211; but we would certainly have had to search the entire applicatin for every references to the view and tested for side effects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nlitchfield</title>
		<link>http://jonathanlewis.wordpress.com/2012/08/09/debugging-2/#comment-48866</link>
		<dc:creator><![CDATA[nlitchfield]]></dc:creator>
		<pubDate>Thu, 09 Aug 2012 21:31:41 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9309#comment-48866</guid>
		<description><![CDATA[As an aside Jonathan I&#039;m interested in your comment

&quot; we would have been able to work around the problem because the vendor embedded most of the code complexity in views – so we could add hints to the view definitions &quot; 

I think I&#039;d be a bit worried that the hinted view might well make *this* bit of generated code run well (or at least for problem values) but that the view might be in use in multiple places with different semantics and that a hint that benefited us here would be detrimental elsewhere. I wonder how you might triage this potential side effect?]]></description>
		<content:encoded><![CDATA[<p>As an aside Jonathan I&#8217;m interested in your comment</p>
<p>&#8221; we would have been able to work around the problem because the vendor embedded most of the code complexity in views – so we could add hints to the view definitions &#8221; </p>
<p>I think I&#8217;d be a bit worried that the hinted view might well make *this* bit of generated code run well (or at least for problem values) but that the view might be in use in multiple places with different semantics and that a hint that benefited us here would be detrimental elsewhere. I wonder how you might triage this potential side effect?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
