<?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: Why Isn&#8217;t Oracle Using My Outline / Profile / Baseline?</title>
	<atom:link href="http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/feed/" rel="self" type="application/rss+xml" />
	<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/</link>
	<description>Just another Oracle blog</description>
	<pubDate>Thu, 29 Jul 2010 12:00:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-16434</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Wed, 28 Jul 2010 00:35:28 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-16434</guid>
		<description>Kyle,

  I think you must have cut off the last d in the script. The last line should look like this:

) d;

If that's not it, post a little more info (i.e. run the script with echo on and capture the output) and I'll see if I can spot the problem. I haven't had any issues with it on 10.1 - 11.2.

Kerry</description>
		<content:encoded><![CDATA[<p>Kyle,</p>
<p>  I think you must have cut off the last d in the script. The last line should look like this:</p>
<p>) d;</p>
<p>If that&#8217;s not it, post a little more info (i.e. run the script with echo on and capture the output) and I&#8217;ll see if I can spot the problem. I haven&#8217;t had any issues with it on 10.1 - 11.2.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Hailey</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-16425</link>
		<dc:creator>Kyle Hailey</dc:creator>
		<pubDate>Tue, 27 Jul 2010 23:45:43 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-16425</guid>
		<description>with, sql_hints.sql , have you ever seen this:
extractvalue(value(d), '/hint') as outline_hints
                   *
ERROR at line 2:
ORA-00904: \D\: invalid identifier
?
Maybe I'm missing something obvious as I get a similar error with the COE script you posted recently.</description>
		<content:encoded><![CDATA[<p>with, sql_hints.sql , have you ever seen this:<br />
extractvalue(value(d), &#8216;/hint&#8217;) as outline_hints<br />
                   *<br />
ERROR at line 2:<br />
ORA-00904: \D\: invalid identifier<br />
?<br />
Maybe I&#8217;m missing something obvious as I get a similar error with the COE script you posted recently.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-7386</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Tue, 16 Feb 2010 03:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-7386</guid>
		<description>Jon,

  Once a Profile has been created, its hints will be applied (as long as they are valid, and they don't contradict each other, etc...). Since this was a simple Profile with a single directive (INDEX_RS_ASC), when that hint was found to be invalid, it went back to the Full Table Scan. The reason the hint was invalid is because an index range scan cannot be done on an index where the leading columns are not part of the predicate. A skip scan or a full index scan are possible, but not a normal range scan. And since the IGNORE_OPTIM_EMBEDDED_HINTS hint is also included in the Profile, the inline hint in the text is ignored. So basically it's back to picking a plan without any directive hints. At least that's what I believe is happening.

Kerry</description>
		<content:encoded><![CDATA[<p>Jon,</p>
<p>  Once a Profile has been created, its hints will be applied (as long as they are valid, and they don&#8217;t contradict each other, etc&#8230;). Since this was a simple Profile with a single directive (INDEX_RS_ASC), when that hint was found to be invalid, it went back to the Full Table Scan. The reason the hint was invalid is because an index range scan cannot be done on an index where the leading columns are not part of the predicate. A skip scan or a full index scan are possible, but not a normal range scan. And since the IGNORE_OPTIM_EMBEDDED_HINTS hint is also included in the Profile, the inline hint in the text is ignored. So basically it&#8217;s back to picking a plan without any directive hints. At least that&#8217;s what I believe is happening.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Adams</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-7383</link>
		<dc:creator>Jon Adams</dc:creator>
		<pubDate>Tue, 16 Feb 2010 02:39:47 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-7383</guid>
		<description>Kerry,
Is it me or did the explain plain for the index-hinted query appear to have MUCH higher cost in terms of rows processed and CPU?  Perhaps this is the reason the optimizer chose to ignore the profile.</description>
		<content:encoded><![CDATA[<p>Kerry,<br />
Is it me or did the explain plain for the index-hinted query appear to have MUCH higher cost in terms of rows processed and CPU?  Perhaps this is the reason the optimizer chose to ignore the profile.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kerry Osborne&#8217;s Oracle Blog &#187; Blog Archive Single Hint SQL Profiles - Kerry Osborne’s Oracle Blog</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-6901</link>
		<dc:creator>Kerry Osborne&#8217;s Oracle Blog &#187; Blog Archive Single Hint SQL Profiles - Kerry Osborne’s Oracle Blog</dc:creator>
		<pubDate>Mon, 01 Feb 2010 21:25:26 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-6901</guid>
		<description>[...] regarding SQL Profiles (in a very nice collegial sort of way). You can see the original dialog here. One of his main points was that SQL Profiles were not meant to be a generic mechanism for forcing [...]</description>
		<content:encoded><![CDATA[<p>[...] regarding SQL Profiles (in a very nice collegial sort of way). You can see the original dialog here. One of his main points was that SQL Profiles were not meant to be a generic mechanism for forcing [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-5721</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Sun, 22 Nov 2009 20:39:57 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-5721</guid>
		<description>Jonathan, 

a) I agree that Profiles appear to have been built with statistical modifications in mind. It looks to me like they "borrowed" the code from Outlines though. Adding the ability to do the "force matching" thing that let's them apply to multiple statements that only differ due to literals. My experience with the Profiles generated by SQL Tuning Advisor has not been very good in terms of plan stability though. It does not appear that they have any concept of changes to stats and just apply their scaling to what ever the optimizer comes up with. So if (I should say when) the stats change, the scaling factors may not be correct anymore. I can see them working well for situations where the stats gathering is managed tightly and the optimizer just has no way to deal with a particular situation (like correlated columns or example), but for the general case, they seem to "sour" over time due to changing stats. 

Yes, I have seen other hints. We have a client that has created many Profiles with the Tuning Advisor (they are in the process of getting rid of them by the way, due to this tendency to "sour" over time). But back to question about additional hints, I just did a quick review of about 40 Profiles and the vast majority have only statistical hints (OPT_ESTIMATE, COLUMN_STATS, TABLE_STATS, INDEX_STATS). A few have some variation of the (ALL_ROWS, FIRST_ROWS(X)) hint and most have the OPTIMIZER_FEATURES_ENABLE hint as well. To my surprise, I found a couple that had IGNORE_OPTIM_EMBEDDED_HINTS as you were expecting. Even more surprising was that one of the statements had no embedded hints while the other did. (something else to look at I guess) I did find one that had a whole slew of hints. Again, I'm not sure why occasionally we get ones that look like this, but at any rate here's the list of hints:

OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("E"@"SEL$1", "B"@"SEL$1", "A"@"SEL$1", "X"@"SEL$2"), SCALE_ROWS=135.982493)
IGNORE_OPTIM_EMBEDDED_HINTS
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("F"@"SEL$1", "B"@"SEL$1"), SCALE_ROWS=26.34181566)
OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
OPT_ESTIMATE(@"SEL$5DA710D3", INDEX_FILTER, "F"@"SEL$1", IDX$$_1AA260002, SCALE_ROWS=8.883203639e-06)
OPT_PARAM('optimizer_index_cost_adj' 80)
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("D"@"SEL$1", "C"@"SEL$1", "A"@"SEL$1", "X"@"SEL$2"), SCALE_ROWS=1.308307653)
OPT_PARAM('optimizer_index_caching' 60)
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("E"@"SEL$1", "D"@"SEL$1", "C"@"SEL$1", "B"@"SEL$1", "A"@"SEL$1", "Y"@"SEL$2"), SCALE_ROWS=862.9359462)
ALL_ROWS
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("E"@"SEL$1", "A"@"SEL$1"), SCALE_ROWS=25.60960842)
OUTLINE_LEAF(@"SEL$5DA710D3")
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("C"@"SEL$1", "A"@"SEL$1"), SCALE_ROWS=7.884506683)
UNNEST(@"SEL$2")
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("F"@"SEL$1", "B"@"SEL$1", "A"@"SEL$1"), SCALE_ROWS=839.9683673)
OUTLINE(@"SEL$1")
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("B"@"SEL$1", "A"@"SEL$1"), SCALE_ROWS=4.446153275)
OUTLINE(@"SEL$2")
OPT_ESTIMATE(@"SEL$5DA710D3", TABLE, "D"@"SEL$1", SCALE_ROWS=11.39782103)
FULL(@"SEL$5DA710D3" "A"@"SEL$1")
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("E"@"SEL$1", "D"@"SEL$1", "C"@"SEL$1", "A"@"SEL$1"), SCALE_ROWS=259.4309108)
FULL(@"SEL$5DA710D3" "B"@"SEL$1")
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("E"@"SEL$1", "C"@"SEL$1", "A"@"SEL$1"), SCALE_ROWS=190.2944942)
FULL(@"SEL$5DA710D3" "X"@"SEL$2")
OPT_ESTIMATE(@"SEL$5DA710D3", JOIN, ("E"@"SEL$1", "C"@"SEL$1", "A"@"SEL$1", "X"@"SEL$2"), SCALE_ROWS=26.52093258)
INDEX(@"SEL$5DA710D3" "F"@"SEL$1" ("…"))
INDEX_RS_ASC(@"SEL$5DA710D3" "C"@"SEL$1" ("..."))
OPT_ESTIMATE(@"SEL$5DA710D3", INDEX_SKIP_SCAN, "F"@"SEL$1", IDX$$_1AA260002, SCALE_ROWS=8.883203639e-06)
INDEX_RS_ASC(@"SEL$5DA710D3" "E"@"SEL$1" ("..."))
ALL_ROWS
INDEX(@"SEL$5DA710D3" "D"@"SEL$1" ("…"))
LEADING(@"SEL$5DA710D3" "A"@"SEL$1" "B"@"SEL$1" "X"@"SEL$2" "F"@"SEL$1" "C"@"SEL$1" "E"@"SEL$1" "D"@"SEL$1")
USE_HASH(@"SEL$5DA710D3" "B"@"SEL$1")
USE_HASH(@"SEL$5DA710D3" "X"@"SEL$2")
USE_NL(@"SEL$5DA710D3" "F"@"SEL$1")
USE_NL(@"SEL$5DA710D3" "C"@"SEL$1")
USE_NL(@"SEL$5DA710D3" "E"@"SEL$1")
USE_NL(@"SEL$5DA710D3" "D"@"SEL$1")
SWAP_JOIN_INPUTS(@"SEL$5DA710D3" "X"@"SEL$2")

b) Agreed. I am using Profiles in a way that the designers may not have intended. The argument for using Profiles in this manner would be that Profiles can match multiple statements that differ only by literals, while Outlines can't. Profiles are a little cleaner as well. No need for a database trigger to enable them for example. Also, I have to admit that the documentation saying Outlines have been deprecated is starting to make me nervous about using them.

c) Looks like sometimes Profiles include IGNORE_OPTIM_EMBEDDED_HINTS and sometimes they don't. My first thought was maybe the ignore hint was included only when there are embedded hints and it's smart enough to leave the hint out when there aren't any. But I found one that didn't have any embedded hints that still had the ignore hint, so at this point it is unclear to me as to why sometimes it is there and not other times …

d) Yep, my tests showed that the plan can be changed by changing the hints as well, regardless of whether there are any statistical hints there or not. And 11g baselines look to me like enhanced Profiles. Although the Baselines have a plan_hash_value - so they can determine if they got the plan that generated the Baseline to begin with - a giant step forward in my opinion - although I wish they had just saved the plan itself and been done with it. It means they can throw out the whole plan and re-optimize (or pick another baseline), instead of just ignoring a single hint. 

On the bug issue, if I understand you correctly you're saying that creating an Outline also results in the buggy behavior (that being that the plan changes due to the invalid hint). I agree with that observation. Creating an Outline or a Profile in 10g or 11gR1 will change the plan due to this bug. Creating a Baseline in 11gR1 does not change the plan (even though the hint is still messed up) because Baselines are smart enough to know if the plan generated by the hints matches the plan that was originally used to generate the hints. And so, it throws the whole thing out and re-optimizes the statement from scratch.

Thanks for all the thoughtful comments.

Kerry</description>
		<content:encoded><![CDATA[<p>Jonathan, </p>
<p>a) I agree that Profiles appear to have been built with statistical modifications in mind. It looks to me like they &#8220;borrowed&#8221; the code from Outlines though. Adding the ability to do the &#8220;force matching&#8221; thing that let&#8217;s them apply to multiple statements that only differ due to literals. My experience with the Profiles generated by SQL Tuning Advisor has not been very good in terms of plan stability though. It does not appear that they have any concept of changes to stats and just apply their scaling to what ever the optimizer comes up with. So if (I should say when) the stats change, the scaling factors may not be correct anymore. I can see them working well for situations where the stats gathering is managed tightly and the optimizer just has no way to deal with a particular situation (like correlated columns or example), but for the general case, they seem to &#8220;sour&#8221; over time due to changing stats. </p>
<p>Yes, I have seen other hints. We have a client that has created many Profiles with the Tuning Advisor (they are in the process of getting rid of them by the way, due to this tendency to &#8220;sour&#8221; over time). But back to question about additional hints, I just did a quick review of about 40 Profiles and the vast majority have only statistical hints (OPT_ESTIMATE, COLUMN_STATS, TABLE_STATS, INDEX_STATS). A few have some variation of the (ALL_ROWS, FIRST_ROWS(X)) hint and most have the OPTIMIZER_FEATURES_ENABLE hint as well. To my surprise, I found a couple that had IGNORE_OPTIM_EMBEDDED_HINTS as you were expecting. Even more surprising was that one of the statements had no embedded hints while the other did. (something else to look at I guess) I did find one that had a whole slew of hints. Again, I&#8217;m not sure why occasionally we get ones that look like this, but at any rate here&#8217;s the list of hints:</p>
<p>OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;E&#8221;@&#8221;SEL$1&#8243;, &#8220;B&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;, &#8220;X&#8221;@&#8221;SEL$2&#8243;), SCALE_ROWS=135.982493)<br />
IGNORE_OPTIM_EMBEDDED_HINTS<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;F&#8221;@&#8221;SEL$1&#8243;, &#8220;B&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=26.34181566)<br />
OPTIMIZER_FEATURES_ENABLE(&#8217;10.2.0.4&#8242;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, INDEX_FILTER, &#8220;F&#8221;@&#8221;SEL$1&#8243;, IDX$$_1AA260002, SCALE_ROWS=8.883203639e-06)<br />
OPT_PARAM(&#8217;optimizer_index_cost_adj&#8217; 80)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;D&#8221;@&#8221;SEL$1&#8243;, &#8220;C&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;, &#8220;X&#8221;@&#8221;SEL$2&#8243;), SCALE_ROWS=1.308307653)<br />
OPT_PARAM(&#8217;optimizer_index_caching&#8217; 60)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;E&#8221;@&#8221;SEL$1&#8243;, &#8220;D&#8221;@&#8221;SEL$1&#8243;, &#8220;C&#8221;@&#8221;SEL$1&#8243;, &#8220;B&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;, &#8220;Y&#8221;@&#8221;SEL$2&#8243;), SCALE_ROWS=862.9359462)<br />
ALL_ROWS<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;E&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=25.60960842)<br />
OUTLINE_LEAF(@&#8221;SEL$5DA710D3&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;C&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=7.884506683)<br />
UNNEST(@&#8221;SEL$2&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;F&#8221;@&#8221;SEL$1&#8243;, &#8220;B&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=839.9683673)<br />
OUTLINE(@&#8221;SEL$1&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;B&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=4.446153275)<br />
OUTLINE(@&#8221;SEL$2&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, TABLE, &#8220;D&#8221;@&#8221;SEL$1&#8243;, SCALE_ROWS=11.39782103)<br />
FULL(@&#8221;SEL$5DA710D3&#8243; &#8220;A&#8221;@&#8221;SEL$1&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;E&#8221;@&#8221;SEL$1&#8243;, &#8220;D&#8221;@&#8221;SEL$1&#8243;, &#8220;C&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=259.4309108)<br />
FULL(@&#8221;SEL$5DA710D3&#8243; &#8220;B&#8221;@&#8221;SEL$1&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;E&#8221;@&#8221;SEL$1&#8243;, &#8220;C&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;), SCALE_ROWS=190.2944942)<br />
FULL(@&#8221;SEL$5DA710D3&#8243; &#8220;X&#8221;@&#8221;SEL$2&#8243;)<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, JOIN, (&#8221;E&#8221;@&#8221;SEL$1&#8243;, &#8220;C&#8221;@&#8221;SEL$1&#8243;, &#8220;A&#8221;@&#8221;SEL$1&#8243;, &#8220;X&#8221;@&#8221;SEL$2&#8243;), SCALE_ROWS=26.52093258)<br />
INDEX(@&#8221;SEL$5DA710D3&#8243; &#8220;F&#8221;@&#8221;SEL$1&#8243; (&#8221;…&#8221;))<br />
INDEX_RS_ASC(@&#8221;SEL$5DA710D3&#8243; &#8220;C&#8221;@&#8221;SEL$1&#8243; (&#8221;&#8230;&#8221;))<br />
OPT_ESTIMATE(@&#8221;SEL$5DA710D3&#8243;, INDEX_SKIP_SCAN, &#8220;F&#8221;@&#8221;SEL$1&#8243;, IDX$$_1AA260002, SCALE_ROWS=8.883203639e-06)<br />
INDEX_RS_ASC(@&#8221;SEL$5DA710D3&#8243; &#8220;E&#8221;@&#8221;SEL$1&#8243; (&#8221;&#8230;&#8221;))<br />
ALL_ROWS<br />
INDEX(@&#8221;SEL$5DA710D3&#8243; &#8220;D&#8221;@&#8221;SEL$1&#8243; (&#8221;…&#8221;))<br />
LEADING(@&#8221;SEL$5DA710D3&#8243; &#8220;A&#8221;@&#8221;SEL$1&#8243; &#8220;B&#8221;@&#8221;SEL$1&#8243; &#8220;X&#8221;@&#8221;SEL$2&#8243; &#8220;F&#8221;@&#8221;SEL$1&#8243; &#8220;C&#8221;@&#8221;SEL$1&#8243; &#8220;E&#8221;@&#8221;SEL$1&#8243; &#8220;D&#8221;@&#8221;SEL$1&#8243;)<br />
USE_HASH(@&#8221;SEL$5DA710D3&#8243; &#8220;B&#8221;@&#8221;SEL$1&#8243;)<br />
USE_HASH(@&#8221;SEL$5DA710D3&#8243; &#8220;X&#8221;@&#8221;SEL$2&#8243;)<br />
USE_NL(@&#8221;SEL$5DA710D3&#8243; &#8220;F&#8221;@&#8221;SEL$1&#8243;)<br />
USE_NL(@&#8221;SEL$5DA710D3&#8243; &#8220;C&#8221;@&#8221;SEL$1&#8243;)<br />
USE_NL(@&#8221;SEL$5DA710D3&#8243; &#8220;E&#8221;@&#8221;SEL$1&#8243;)<br />
USE_NL(@&#8221;SEL$5DA710D3&#8243; &#8220;D&#8221;@&#8221;SEL$1&#8243;)<br />
SWAP_JOIN_INPUTS(@&#8221;SEL$5DA710D3&#8243; &#8220;X&#8221;@&#8221;SEL$2&#8243;)</p>
<p>b) Agreed. I am using Profiles in a way that the designers may not have intended. The argument for using Profiles in this manner would be that Profiles can match multiple statements that differ only by literals, while Outlines can&#8217;t. Profiles are a little cleaner as well. No need for a database trigger to enable them for example. Also, I have to admit that the documentation saying Outlines have been deprecated is starting to make me nervous about using them.</p>
<p>c) Looks like sometimes Profiles include IGNORE_OPTIM_EMBEDDED_HINTS and sometimes they don&#8217;t. My first thought was maybe the ignore hint was included only when there are embedded hints and it&#8217;s smart enough to leave the hint out when there aren&#8217;t any. But I found one that didn&#8217;t have any embedded hints that still had the ignore hint, so at this point it is unclear to me as to why sometimes it is there and not other times …</p>
<p>d) Yep, my tests showed that the plan can be changed by changing the hints as well, regardless of whether there are any statistical hints there or not. And 11g baselines look to me like enhanced Profiles. Although the Baselines have a plan_hash_value - so they can determine if they got the plan that generated the Baseline to begin with - a giant step forward in my opinion - although I wish they had just saved the plan itself and been done with it. It means they can throw out the whole plan and re-optimize (or pick another baseline), instead of just ignoring a single hint. </p>
<p>On the bug issue, if I understand you correctly you&#8217;re saying that creating an Outline also results in the buggy behavior (that being that the plan changes due to the invalid hint). I agree with that observation. Creating an Outline or a Profile in 10g or 11gR1 will change the plan due to this bug. Creating a Baseline in 11gR1 does not change the plan (even though the hint is still messed up) because Baselines are smart enough to know if the plan generated by the hints matches the plan that was originally used to generate the hints. And so, it throws the whole thing out and re-optimizes the statement from scratch.</p>
<p>Thanks for all the thoughtful comments.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-5716</link>
		<dc:creator>Jonathan Lewis</dc:creator>
		<pubDate>Sun, 22 Nov 2009 08:44:02 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-5716</guid>
		<description>Kerry,

a) Outlines vs. profiles: I think these can be viewed on two levels.  On one hand they are both represented by a set of hints; on the other hand they exist for different reasons. In principle an outline fixes an execution plan so that it can't change whereas a profile fixes the optimizer's understanding of the data distribution pattern so that it can still pick the right plan as the data size varies.

(Other than optimizer_features_enable() and ignore_optim_embedded_hints, I've not seen anything but statistical hints in a profile generated by the tuning tool - do you have any examples to demonstrate otherwise ?).

b) One aspect of the difference between outlines and profiles is that the profiling information doesn't get into the outline when the statement runs.  A statement with a profile can produce many different execution plans - which means many different outlines: which, I'd say, is an argument against copying an outline into the profile table.

c) disabling embedded hints - I think I was wrong, but I'm not 100% sure.  I've just run up an example in 11.1.0.6 to demonstrate the point - and realised that the profile included the 'optim_ignore_embedded_hints' hint, so perhaps there are cases where this isn't included and embedded hints are still obeyed.  (In fact, since you were copying from the outline, you automatically copied in the optim_ignore_embedded_hints hint anyway - and then the index_rs_asc() hint was ignored because it is invalid in this context (as you suggested), and shouldn't have been genereated by the optimizer).

d) That's a valid test that the code for applying profiles doesn't care what type of hint you've put in the table - and it certainly seemed to be true for a couple of examples I've just created. It certainly makes sense - especially in view of the fact that sql-baselines are written into the same table in 11g (Why have two different pieces of code when one will do ?) 


Regards
Jonathan Lewis</description>
		<content:encoded><![CDATA[<p>Kerry,</p>
<p>a) Outlines vs. profiles: I think these can be viewed on two levels.  On one hand they are both represented by a set of hints; on the other hand they exist for different reasons. In principle an outline fixes an execution plan so that it can&#8217;t change whereas a profile fixes the optimizer&#8217;s understanding of the data distribution pattern so that it can still pick the right plan as the data size varies.</p>
<p>(Other than optimizer_features_enable() and ignore_optim_embedded_hints, I&#8217;ve not seen anything but statistical hints in a profile generated by the tuning tool - do you have any examples to demonstrate otherwise ?).</p>
<p>b) One aspect of the difference between outlines and profiles is that the profiling information doesn&#8217;t get into the outline when the statement runs.  A statement with a profile can produce many different execution plans - which means many different outlines: which, I&#8217;d say, is an argument against copying an outline into the profile table.</p>
<p>c) disabling embedded hints - I think I was wrong, but I&#8217;m not 100% sure.  I&#8217;ve just run up an example in 11.1.0.6 to demonstrate the point - and realised that the profile included the &#8216;optim_ignore_embedded_hints&#8217; hint, so perhaps there are cases where this isn&#8217;t included and embedded hints are still obeyed.  (In fact, since you were copying from the outline, you automatically copied in the optim_ignore_embedded_hints hint anyway - and then the index_rs_asc() hint was ignored because it is invalid in this context (as you suggested), and shouldn&#8217;t have been genereated by the optimizer).</p>
<p>d) That&#8217;s a valid test that the code for applying profiles doesn&#8217;t care what type of hint you&#8217;ve put in the table - and it certainly seemed to be true for a couple of examples I&#8217;ve just created. It certainly makes sense - especially in view of the fact that sql-baselines are written into the same table in 11g (Why have two different pieces of code when one will do ?) </p>
<p>Regards<br />
Jonathan Lewis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-5713</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Sun, 22 Nov 2009 04:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-5713</guid>
		<description>Jonathan,

Wow - I had to think about this one for a while (and go back to check my work) - here's my thoughts:


a) A profile and an outline are different things - roughly speaking an outline lists actions and strategies, a profile supplies statistical corrections to the optimizer.

I see Outlines and Profiles (and Baselines for that matter) as basically the same thing. They apply a set of hints to a statement. The standard (documented) way of generating a SQL Profile is to use the the SQL Tuning Advisor - which does calculate scaling factors to apply to various steps and implements them via the OPT_ESTIMATE, TABLE_STATS, COLUMN_STATS hints (and occasionally it adds some strategic type hints…). But Profiles are nevertheless just applying hints (I think).


b) The code you've used to "create a profile from the shared pool" doesn't, it copies an outline from the shared pool but tells the optimizer it's a profile.

That comment made me laugh - you're absolutely right of course! But just to be clear to anyone else that might stumble across this dialog, every plan has a set of hints that Oracle thinks will recreate the plan (stored in the other_xml column of v$sql_plan). These hints are the exact hints that are used when you create an Outline. The code in my create_sql_profile.sql script does exactly what you said, it creates a SQL Profile using that same set of hints that would be in the Outline if you created one for the statement.


c) When you run (or explain) the query with the "profile" in place, the optimizer detects the profile and disables the embedded hints (i.e. the ones in the actual text) and tries to derive an execution plan based on what ought to be statistical content in the profile combined with the basic object stats. But the profile supplies no statistical information.

I believe SQL Profiles apply the hints. I don't think they expect any specific statistical information (i.e. I don't think they care whether there are any OPT_ESTIMATE, TABLE_STATS, or COLUMN_STATS hints or not) I could be wrong, but I haven't seen any situation where a Profile was ignored because it didn't have statistical information. 

As a side note, I don't think the SQL Profiles that are created by the SQL Tuning Advisor disable embedded hints the way Outlines do. I say this because Outline hints include the IGNORE_OPTIM_EMBEDDED_HINTS hint and SQL Profiles created by the Tuning Advisor do not. And if you think about it, that makes sense. Since the latter are basically only supplying statistical information, disabling embedded hints would not make sense. (Note: I have not done a specific test to prove this to myself)


d) In the absence of statistical information, and after disabling the embedded hints, the optimizer has "used" the profile but produces the original, unhinted, tablescan plan.

I came up with a little test case. See if you think this is a valid test.

  1. create a SQL Profile (based on hints from other_xml)
  2. check hints - there will be no statistical hints
  3. manually modify one of the hints in a way that forces a different plan
  4. see if it works

If the plan changes as expected, despite the absence of any statistical hints, then that implies to me that Profiles just apply whatever hints are there. Thoughts?

Kerry</description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>Wow - I had to think about this one for a while (and go back to check my work) - here&#8217;s my thoughts:</p>
<p>a) A profile and an outline are different things - roughly speaking an outline lists actions and strategies, a profile supplies statistical corrections to the optimizer.</p>
<p>I see Outlines and Profiles (and Baselines for that matter) as basically the same thing. They apply a set of hints to a statement. The standard (documented) way of generating a SQL Profile is to use the the SQL Tuning Advisor - which does calculate scaling factors to apply to various steps and implements them via the OPT_ESTIMATE, TABLE_STATS, COLUMN_STATS hints (and occasionally it adds some strategic type hints…). But Profiles are nevertheless just applying hints (I think).</p>
<p>b) The code you&#8217;ve used to &#8220;create a profile from the shared pool&#8221; doesn&#8217;t, it copies an outline from the shared pool but tells the optimizer it&#8217;s a profile.</p>
<p>That comment made me laugh - you&#8217;re absolutely right of course! But just to be clear to anyone else that might stumble across this dialog, every plan has a set of hints that Oracle thinks will recreate the plan (stored in the other_xml column of v$sql_plan). These hints are the exact hints that are used when you create an Outline. The code in my create_sql_profile.sql script does exactly what you said, it creates a SQL Profile using that same set of hints that would be in the Outline if you created one for the statement.</p>
<p>c) When you run (or explain) the query with the &#8220;profile&#8221; in place, the optimizer detects the profile and disables the embedded hints (i.e. the ones in the actual text) and tries to derive an execution plan based on what ought to be statistical content in the profile combined with the basic object stats. But the profile supplies no statistical information.</p>
<p>I believe SQL Profiles apply the hints. I don&#8217;t think they expect any specific statistical information (i.e. I don&#8217;t think they care whether there are any OPT_ESTIMATE, TABLE_STATS, or COLUMN_STATS hints or not) I could be wrong, but I haven&#8217;t seen any situation where a Profile was ignored because it didn&#8217;t have statistical information. </p>
<p>As a side note, I don&#8217;t think the SQL Profiles that are created by the SQL Tuning Advisor disable embedded hints the way Outlines do. I say this because Outline hints include the IGNORE_OPTIM_EMBEDDED_HINTS hint and SQL Profiles created by the Tuning Advisor do not. And if you think about it, that makes sense. Since the latter are basically only supplying statistical information, disabling embedded hints would not make sense. (Note: I have not done a specific test to prove this to myself)</p>
<p>d) In the absence of statistical information, and after disabling the embedded hints, the optimizer has &#8220;used&#8221; the profile but produces the original, unhinted, tablescan plan.</p>
<p>I came up with a little test case. See if you think this is a valid test.</p>
<p>  1. create a SQL Profile (based on hints from other_xml)<br />
  2. check hints - there will be no statistical hints<br />
  3. manually modify one of the hints in a way that forces a different plan<br />
  4. see if it works</p>
<p>If the plan changes as expected, despite the absence of any statistical hints, then that implies to me that Profiles just apply whatever hints are there. Thoughts?</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-5710</link>
		<dc:creator>Jonathan Lewis</dc:creator>
		<pubDate>Sat, 21 Nov 2009 23:20:37 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-5710</guid>
		<description>Kerry,

I'd like to suggest a different interpretation of your results.

a) A profile and an outline are different things - roughly speaking an outline lists actions and strategies, a profile supplies statistical corrections to the optimizer.

b) The code you've used to "create a profile from the shared pool" doesn't, it copies an outline from the shared pool but tells the optimizer it's a profile.

c) When you run (or explain) the query with the "profile" in place, the optimizer detects the profile and disables the embedded hints (i.e. the ones in the actual text) and tries to derive an execution plan based on what ought to be statistical content in the profile combined with the basic object stats. But the profile supplies no statistical information.

d) In the absence of statistical information, and after disabling the embedded hints, the optimizer has "used" the profile but produces the original, unhinted, tablescan plan.

Regards
Jonathan Lewis</description>
		<content:encoded><![CDATA[<p>Kerry,</p>
<p>I&#8217;d like to suggest a different interpretation of your results.</p>
<p>a) A profile and an outline are different things - roughly speaking an outline lists actions and strategies, a profile supplies statistical corrections to the optimizer.</p>
<p>b) The code you&#8217;ve used to &#8220;create a profile from the shared pool&#8221; doesn&#8217;t, it copies an outline from the shared pool but tells the optimizer it&#8217;s a profile.</p>
<p>c) When you run (or explain) the query with the &#8220;profile&#8221; in place, the optimizer detects the profile and disables the embedded hints (i.e. the ones in the actual text) and tries to derive an execution plan based on what ought to be statistical content in the profile combined with the basic object stats. But the profile supplies no statistical information.</p>
<p>d) In the absence of statistical information, and after disabling the embedded hints, the optimizer has &#8220;used&#8221; the profile but produces the original, unhinted, tablescan plan.</p>
<p>Regards<br />
Jonathan Lewis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kerry Osborne&#8217;s Oracle Blog &#187; Blog Archive Fixing Bad Index Hints in SQL Profiles (automatically) - Kerry Osborne’s Oracle Blog</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/#comment-5670</link>
		<dc:creator>Kerry Osborne&#8217;s Oracle Blog &#187; Blog Archive Fixing Bad Index Hints in SQL Profiles (automatically) - Kerry Osborne’s Oracle Blog</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1668#comment-5670</guid>
		<description>[...] on the change Oracle made to their Hint based mechanisms (Outlines/Profiles/Baselines) in 10g here: Why Isn&#8217;t Oracle Using My Outline / Profile / Baseline. To quickly recap, prior to 10g, the design goal for Outlines appears to have been to [...]</description>
		<content:encoded><![CDATA[<p>[...] on the change Oracle made to their Hint based mechanisms (Outlines/Profiles/Baselines) in 10g here: Why Isn&#8217;t Oracle Using My Outline / Profile / Baseline. To quickly recap, prior to 10g, the design goal for Outlines appears to have been to [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
