<?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"
	>
<channel>
	<title>Comments on: Fixing Bad Index Hints in SQL Profiles (automatically)</title>
	<atom:link href="http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/feed/" rel="self" type="application/rss+xml" />
	<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/</link>
	<description>Just another Oracle blog</description>
	<pubDate>Sat, 13 Mar 2010 15:19:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: force_match &#171; Oracle Scratchpad</title>
		<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/#comment-6422</link>
		<dc:creator>force_match &#171; Oracle Scratchpad</dc:creator>
		<pubDate>Tue, 12 Jan 2010 19:21:24 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1989#comment-6422</guid>
		<description>[...] Jonathan Lewis @ 7:19 pm UTC Jan 12,2010   If you have looked at SQL Profiles (see for example Kerry Osborne&#8217;s blog) then you may have come across the force_match option for enabling or importing a SQL profile. I [...]</description>
		<content:encoded><![CDATA[<p>[...] Jonathan Lewis @ 7:19 pm UTC Jan 12,2010   If you have looked at SQL Profiles (see for example Kerry Osborne&#8217;s blog) then you may have come across the force_match option for enabling or importing a SQL profile. I [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Fontana</title>
		<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/#comment-5732</link>
		<dc:creator>Michael Fontana</dc:creator>
		<pubDate>Mon, 23 Nov 2009 21:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1989#comment-5732</guid>
		<description>I like the suggestion of having Oracle issue a warning when a hint is syntactically incorrect and will be ignored.  A more powerful (and probably quite difficult) behavioral change would be to have Oracle indicate when it uses a different path than what was specified (or implied????) by the hint.  This has always been such a vague and esoteric area.  I wonder where an enhancement request with Oracle support would end up?</description>
		<content:encoded><![CDATA[<p>I like the suggestion of having Oracle issue a warning when a hint is syntactically incorrect and will be ignored.  A more powerful (and probably quite difficult) behavioral change would be to have Oracle indicate when it uses a different path than what was specified (or implied????) by the hint.  This has always been such a vague and esoteric area.  I wonder where an enhancement request with Oracle support would end up?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blogroll Report 13/11/2009-20/11/2009 &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/#comment-5722</link>
		<dc:creator>Blogroll Report 13/11/2009-20/11/2009 &#171; Coskan&#8217;s Approach to Oracle</dc:creator>
		<pubDate>Sun, 22 Nov 2009 21:42:33 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1989#comment-5722</guid>
		<description>[...] 14-How to change index hints with new index hint format automatically in sql profiles? Kerry Osborne-Fixing Bad Index Hints in SQL Profiles (automatically) [...]</description>
		<content:encoded><![CDATA[<p>[...] 14-How to change index hints with new index hint format automatically in sql profiles? Kerry Osborne-Fixing Bad Index Hints in SQL Profiles (automatically) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/#comment-5712</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Sun, 22 Nov 2009 01:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1989#comment-5712</guid>
		<description>Jonathan, 

Thanks for the comments. 

I totally agree that your paraphrase of what the index hint is saying is more accurate than mine. (too bad they don't document hints better, and that they don't have the option to raise a warning when they are ignored).

I also agree that the INDEX_RS(_ASC/DSC) hints are more specific and therefore a better choice when trying to force a specific plan. Unfortunately, there are some problems (i.e. bug) that cause Oracle to create an invalid hint. In the particular case I showed (2nd batch of code), the other_xml field contains the hint 

INDEX_RS_ASC(@"SEL$1" "A"@"SEL$1" ("SKEW"."COL2" "SKEW"."COL1"))

 - even though the actual plan does an 

INDEX FULL SCAN

Therefore, creating an Outline on this statement changes the plan. In this case, changing the hint to the more generic INDEX(xxx), allows the optimizer to use an INDEX FULL SCAN. By the way, 11.2 works around this bug by doing exactly that, changing the INDEX_RS_ASC to INDEX. So I am agreeing with you on this point as well, more specific is certainly better (unless of course it doesn't work, like in this corner case).

I'm not much of a fan of the new index format though. I understand your point about changing indexes and in general it makes sense. With respect to Outlines/Profiles/Baselines though it seems too flexible at times. By that I mean that occasionally an Outline or Profile will not keep a plan from changing - and sometimes it's due to this non-specific Index Hint format. I think one of the reasons is that the Outline Hint created by Oracle (again pulled from the other_xml field) specifies every column contained in the index. That is to say that if a plan uses an index that contains 10 columns, all ten will be listed in the hint, regardless of the fact that only a couple of them may actually be used in the statement. You can see this in the example in the post as well. The SKEW_COL2_COL1 index has COL2 and COL1. So the hints specifies both columns, even though the SQL only references COL1. I guess it just seems more straight forward and less error prone to actually specify the index name (although I acknowledge that it may go bad at some point in the future if someone changes the indexes). 

Thanks again for your comments. 

Note: I'll have to do a little verification (and refreshing my memory) before I respond to your comments on  
&lt;a href="http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/" rel="nofollow"&gt;Why Isn't Oracle Using My Outline / Profile / Baseline&lt;/a&gt;.

Kerry</description>
		<content:encoded><![CDATA[<p>Jonathan, </p>
<p>Thanks for the comments. </p>
<p>I totally agree that your paraphrase of what the index hint is saying is more accurate than mine. (too bad they don&#8217;t document hints better, and that they don&#8217;t have the option to raise a warning when they are ignored).</p>
<p>I also agree that the INDEX_RS(_ASC/DSC) hints are more specific and therefore a better choice when trying to force a specific plan. Unfortunately, there are some problems (i.e. bug) that cause Oracle to create an invalid hint. In the particular case I showed (2nd batch of code), the other_xml field contains the hint </p>
<p>INDEX_RS_ASC(@&#8221;SEL$1&#8243; &#8220;A&#8221;@&#8221;SEL$1&#8243; (&#8221;SKEW&#8221;.&#8221;COL2&#8243; &#8220;SKEW&#8221;.&#8221;COL1&#8243;))</p>
<p> - even though the actual plan does an </p>
<p>INDEX FULL SCAN</p>
<p>Therefore, creating an Outline on this statement changes the plan. In this case, changing the hint to the more generic INDEX(xxx), allows the optimizer to use an INDEX FULL SCAN. By the way, 11.2 works around this bug by doing exactly that, changing the INDEX_RS_ASC to INDEX. So I am agreeing with you on this point as well, more specific is certainly better (unless of course it doesn&#8217;t work, like in this corner case).</p>
<p>I&#8217;m not much of a fan of the new index format though. I understand your point about changing indexes and in general it makes sense. With respect to Outlines/Profiles/Baselines though it seems too flexible at times. By that I mean that occasionally an Outline or Profile will not keep a plan from changing - and sometimes it&#8217;s due to this non-specific Index Hint format. I think one of the reasons is that the Outline Hint created by Oracle (again pulled from the other_xml field) specifies every column contained in the index. That is to say that if a plan uses an index that contains 10 columns, all ten will be listed in the hint, regardless of the fact that only a couple of them may actually be used in the statement. You can see this in the example in the post as well. The SKEW_COL2_COL1 index has COL2 and COL1. So the hints specifies both columns, even though the SQL only references COL1. I guess it just seems more straight forward and less error prone to actually specify the index name (although I acknowledge that it may go bad at some point in the future if someone changes the indexes). </p>
<p>Thanks again for your comments. </p>
<p>Note: I&#8217;ll have to do a little verification (and refreshing my memory) before I respond to your comments on<br />
<a href="http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/"  rel="nofollow">Why Isn&#8217;t Oracle Using My Outline / Profile / Baseline</a>.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/#comment-5711</link>
		<dc:creator>Jonathan Lewis</dc:creator>
		<pubDate>Sat, 21 Nov 2009 23:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1989#comment-5711</guid>
		<description>Kerry:

Regarding this comment:
&lt;i&gt;
INDEX(TABLE_NAME.COLUMN_NAME TABLE.NAME.COLUMN_NAME …)
Translation: If possible, use any available index on any of these columns.
&lt;/i&gt;

I think the translation should be more like: 

&lt;i&gt;"Use the index on this set of columns in this order but if the required index doesn't exist then use the cheapest index that starts with this set of columns in this order."&lt;/i&gt;

Personally I think it's a better way of hinting an index than the old "index(alias index_name)" method given that (a) people sometimes rename indexes to conform to naming conventions and (b) people sometimes drop one index because it starts the same way as another.  In both cases, the new mechanism is likely to reduce the risk of damage.

The "index_rs(_asc/_desc)" hints were introduced, by the way, because an index() hint could allow the optimizer to choose between a range scan and a full scan - and that meant that a hinted query could still change its execution path dramatically unless all the other hints had been carefully set up to avoid the error - so I wouldn't be too keen to change a index range scan hint to a simple index hint.

Regards
Jonathan Lewis</description>
		<content:encoded><![CDATA[<p>Kerry:</p>
<p>Regarding this comment:<br />
<i><br />
INDEX(TABLE_NAME.COLUMN_NAME TABLE.NAME.COLUMN_NAME …)<br />
Translation: If possible, use any available index on any of these columns.<br />
</i></p>
<p>I think the translation should be more like: </p>
<p><i>&#8220;Use the index on this set of columns in this order but if the required index doesn&#8217;t exist then use the cheapest index that starts with this set of columns in this order.&#8221;</i></p>
<p>Personally I think it&#8217;s a better way of hinting an index than the old &#8220;index(alias index_name)&#8221; method given that (a) people sometimes rename indexes to conform to naming conventions and (b) people sometimes drop one index because it starts the same way as another.  In both cases, the new mechanism is likely to reduce the risk of damage.</p>
<p>The &#8220;index_rs(_asc/_desc)&#8221; hints were introduced, by the way, because an index() hint could allow the optimizer to choose between a range scan and a full scan - and that meant that a hinted query could still change its execution path dramatically unless all the other hints had been carefully set up to avoid the error - so I wouldn&#8217;t be too keen to change a index range scan hint to a simple index hint.</p>
<p>Regards<br />
Jonathan Lewis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #170: a Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://kerryosborne.oracle-guy.com/2009/11/fixing-bad-index-hints-in-sql-profiles-automatically/#comment-5697</link>
		<dc:creator>Log Buffer #170: a Carnival of the Vanities for DBAs &#124; The Pythian Blog</dc:creator>
		<pubDate>Fri, 20 Nov 2009 17:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1989#comment-5697</guid>
		<description>[...] Osborne gives a lesson on fixing bad index hints in SQL Profiles (automatically). He says, &#8220;With 10g and 11g, it appears the goal [or Outlines] has swung away from the [...]</description>
		<content:encoded><![CDATA[<p>[...] Osborne gives a lesson on fixing bad index hints in SQL Profiles (automatically). He says, &#8220;With 10g and 11g, it appears the goal [or Outlines] has swung away from the [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
