<?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: How to hint &#8211; 1</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 22 May 2013 12:40:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL Patch IV (or Part II Addendum) &#8211; Why is the SQL Patch applied but not effective? &#171; OraStory</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-45773</link>
		<dc:creator><![CDATA[SQL Patch IV (or Part II Addendum) &#8211; Why is the SQL Patch applied but not effective? &#171; OraStory]]></dc:creator>
		<pubDate>Thu, 29 Mar 2012 12:28:51 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-45773</guid>
		<description><![CDATA[[...] the complete hint specification becomes ever more important. See Jonathan Lewis&#8217;s How to Hint post for a good [...]]]></description>
		<content:encoded><![CDATA[<p>[...] the complete hint specification becomes ever more important. See Jonathan Lewis&#8217;s How to Hint post for a good [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geek Stuff &#171; Oracle Scratchpad</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-45182</link>
		<dc:creator><![CDATA[Geek Stuff &#171; Oracle Scratchpad]]></dc:creator>
		<pubDate>Mon, 27 Feb 2012 17:52:17 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-45182</guid>
		<description><![CDATA[[...] a possible hint set that works 10.2.0.3 &#8211; I identified the necessary query block name by using the &#8216;outline&#8217; option of dbms_xplan to check the execution [...]]]></description>
		<content:encoded><![CDATA[<p>[...] a possible hint set that works 10.2.0.3 &#8211; I identified the necessary query block name by using the &#8216;outline&#8217; option of dbms_xplan to check the execution [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hints of Acceptability &#171; OraStory</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-43089</link>
		<dc:creator><![CDATA[Hints of Acceptability &#171; OraStory]]></dc:creator>
		<pubDate>Mon, 12 Dec 2011 21:49:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-43089</guid>
		<description><![CDATA[[...] For more information on what you have to do to properly hint, see this excellent article on by Jonathan Lewis. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] For more information on what you have to do to properly hint, see this excellent article on by Jonathan Lewis. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavol Babel</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40759</link>
		<dc:creator><![CDATA[Pavol Babel]]></dc:creator>
		<pubDate>Mon, 13 Jun 2011 18:33:55 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40759</guid>
		<description><![CDATA[I agree, it is very reasonable to avoid hints, if possible. But it depends of complexity of application. Unfortunately, we have to still hint complex queries. But we definitely try to use different techniques (setting statistics, adjust system statistics etc) and use hints only when really needed.]]></description>
		<content:encoded><![CDATA[<p>I agree, it is very reasonable to avoid hints, if possible. But it depends of complexity of application. Unfortunately, we have to still hint complex queries. But we definitely try to use different techniques (setting statistics, adjust system statistics etc) and use hints only when really needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Brady</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40756</link>
		<dc:creator><![CDATA[John Brady]]></dc:creator>
		<pubDate>Mon, 13 Jun 2011 09:06:48 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40756</guid>
		<description><![CDATA[Pavol,

I&#039;m with you now on this one - I don&#039;t think the USE_NL (C2) hint I added will have any effect on the optimizer.  Another lesson learned for me about the right ways of using hints, and why it is probably better to just avoid them.  I also think the NO_USE_HASH (C2) would be ignored by the optimizer for the same reason - the reference to C2 is not qualified by the inner query block name.

The hints I have mentioned from the outline section in the 10053 trace file were only from the first execution of the query with no hints at all.  So anything listed in that outline section was put there by the optimizer itself.  I&#039;ve not done a 10053 trace since, so I have no idea what hints were in the outline that resulted from the hinted query.  So USE_HASH was produced by the optimizer itself.  I think I also said that all of the hints from the optimizer outline section were fully qualified - each had a leading &#039;@&#039; top level query block name argument, followed by table aliases each qualified by the query block name within the query e.g. SC@SEL1, C2@SEL2.  

If I wanted a set of &quot;useful&quot; hints then I would now more closely follow Jonathan&#039;s recommendations - use query block names and qualify all table references, and add in as many hints as possible to be totally unambiguous e.g. LEADING, UNNEST and others.

Thanks, John]]></description>
		<content:encoded><![CDATA[<p>Pavol,</p>
<p>I&#8217;m with you now on this one &#8211; I don&#8217;t think the USE_NL (C2) hint I added will have any effect on the optimizer.  Another lesson learned for me about the right ways of using hints, and why it is probably better to just avoid them.  I also think the NO_USE_HASH (C2) would be ignored by the optimizer for the same reason &#8211; the reference to C2 is not qualified by the inner query block name.</p>
<p>The hints I have mentioned from the outline section in the 10053 trace file were only from the first execution of the query with no hints at all.  So anything listed in that outline section was put there by the optimizer itself.  I&#8217;ve not done a 10053 trace since, so I have no idea what hints were in the outline that resulted from the hinted query.  So USE_HASH was produced by the optimizer itself.  I think I also said that all of the hints from the optimizer outline section were fully qualified &#8211; each had a leading &#8216;@&#8217; top level query block name argument, followed by table aliases each qualified by the query block name within the query e.g. SC@SEL1, C2@SEL2.  </p>
<p>If I wanted a set of &#8220;useful&#8221; hints then I would now more closely follow Jonathan&#8217;s recommendations &#8211; use query block names and qualify all table references, and add in as many hints as possible to be totally unambiguous e.g. LEADING, UNNEST and others.</p>
<p>Thanks, John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavol Babel</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40741</link>
		<dc:creator><![CDATA[Pavol Babel]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 15:59:31 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40741</guid>
		<description><![CDATA[John,

answering to some of your notes:

1. Of course EXISTS has been transformed to SEMI JOIN. BTW, I think, this the reason why oracle depricated %_SJ and %_AJ hints (you can always achive semi or anti join by using different hints). But the name od default queryblcock name SEL$1 has been transformed and that&#039;s the problem as Jonathan wrote, too
3. You have seen USE_HASH in the final outline, but you don&#039;t know, weather because of your hint, or not. CBO always generates an outline, also in cases, where no hints were used in original query

I have tried my examples also on 10.2.0.5 Solaris 32 bit and I have same results. Let&#039;s run explain plan on following queries and please, paste us here execution plans
generated on your solaris 64bit box. 

[sourcecode]

CREATE TABLE t1 (n1 NUMBER, n2 NUMBER, v1 VARCHAR2(100))
/
CREATE INDEX t1_i ON t1(n1)
/
CREATE TABLE t2 (n1 NUMBER, n2 NUMBER, v2 VARCHAR2(100))
/

select
   /*+ LEADING(t2) USE_NL(t1) */ *
from
    t2
where   t2.n2 = 15
and exists (
        select
            null
        from    t1
        where   t1.n1 = t2.n1
    )
;

select
   /*+ LEADING(t2) USE_HASH(t1) */ *
from
    t2
where   t2.n2 = 15
and exists (
        select
            null
        from    t1
        where   t1.n1 = t2.n1
    )
;


[/sourcecode]

If the first plan will contain NESTED LOOPS SEMI and the second HASH_JOIN_SEMI, you are right. But as you can see my exampeles abov,  optimizer didn&#039;t follow hints in one of them (I have tried LINUX 64bit, HP 64 bit and Solaris 32bit, all DB were 10.2.0.5 ). I think it will be the same story at your DB and will be the final contradiction of your theory.

Johnathan also suggested that two of your hints are invalid. And yes, OPTIMIZER IGNORES hints when they are not valid (referencing nonexisting tables, indexes etc.).]]></description>
		<content:encoded><![CDATA[<p>John,</p>
<p>answering to some of your notes:</p>
<p>1. Of course EXISTS has been transformed to SEMI JOIN. BTW, I think, this the reason why oracle depricated %_SJ and %_AJ hints (you can always achive semi or anti join by using different hints). But the name od default queryblcock name SEL$1 has been transformed and that&#8217;s the problem as Jonathan wrote, too<br />
3. You have seen USE_HASH in the final outline, but you don&#8217;t know, weather because of your hint, or not. CBO always generates an outline, also in cases, where no hints were used in original query</p>
<p>I have tried my examples also on 10.2.0.5 Solaris 32 bit and I have same results. Let&#8217;s run explain plan on following queries and please, paste us here execution plans<br />
generated on your solaris 64bit box. </p>
<pre class="brush: plain; title: ; notranslate">

CREATE TABLE t1 (n1 NUMBER, n2 NUMBER, v1 VARCHAR2(100))
/
CREATE INDEX t1_i ON t1(n1)
/
CREATE TABLE t2 (n1 NUMBER, n2 NUMBER, v2 VARCHAR2(100))
/

select
   /*+ LEADING(t2) USE_NL(t1) */ *
from
    t2
where   t2.n2 = 15
and exists (
        select
            null
        from    t1
        where   t1.n1 = t2.n1
    )
;

select
   /*+ LEADING(t2) USE_HASH(t1) */ *
from
    t2
where   t2.n2 = 15
and exists (
        select
            null
        from    t1
        where   t1.n1 = t2.n1
    )
;


</pre>
<p>If the first plan will contain NESTED LOOPS SEMI and the second HASH_JOIN_SEMI, you are right. But as you can see my exampeles abov,  optimizer didn&#8217;t follow hints in one of them (I have tried LINUX 64bit, HP 64 bit and Solaris 32bit, all DB were 10.2.0.5 ). I think it will be the same story at your DB and will be the final contradiction of your theory.</p>
<p>Johnathan also suggested that two of your hints are invalid. And yes, OPTIMIZER IGNORES hints when they are not valid (referencing nonexisting tables, indexes etc.).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavol Babel</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40740</link>
		<dc:creator><![CDATA[Pavol Babel]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 15:28:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40740</guid>
		<description><![CDATA[Jonathan,

&quot;We’ll have to agree to differ on our opinions of use_nl(@subq t1) – since there is no definitive statement in the manuals&quot; - I absolutely agree.]]></description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>&#8220;We’ll have to agree to differ on our opinions of use_nl(@subq t1) – since there is no definitive statement in the manuals&#8221; &#8211; I absolutely agree.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Brady</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40738</link>
		<dc:creator><![CDATA[John Brady]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 12:51:11 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40738</guid>
		<description><![CDATA[I was using 10.2.0.4 on a Sun Solaris system.  The top line of the 10053 trace file says:
[code]
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
[/code]
One of the other hints in the outline output of the 10053 trace file was an optimizer features hint:
[code]
OPTIMIZER_FEATURES_ENABLE(&#039;10.2.0.4&#039;)
[/code]
All of this feedback from everyone is just reinforcing my view that hints should be avoided because it is so difficult to know for certain that each hint is individually doing what you want it to.  As Pavol has said, it could be one of the other hints that ended up producing the NESTED LOOP join, rather than the USE_NL (C2) itself - either the NO_USE_HASH or the INDEX on SC.  And as I said before, the second alternative I came up with after some further analysis of reducing the column density value seems safer from the perspective of it more directly controlling the desired impact on the execution plan produced.  &quot;Safe&quot; is a relative term here, as one way or another we are trying to force the Oracle optimizer to pick a different execution plan to the one it naturally believes is &quot;best&quot;.]]></description>
		<content:encoded><![CDATA[<p>I was using 10.2.0.4 on a Sun Solaris system.  The top line of the 10053 trace file says:</p>
<pre class="brush: plain; title: ; notranslate">
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
</pre>
<p>One of the other hints in the outline output of the 10053 trace file was an optimizer features hint:</p>
<pre class="brush: plain; title: ; notranslate">
OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
</pre>
<p>All of this feedback from everyone is just reinforcing my view that hints should be avoided because it is so difficult to know for certain that each hint is individually doing what you want it to.  As Pavol has said, it could be one of the other hints that ended up producing the NESTED LOOP join, rather than the USE_NL (C2) itself &#8211; either the NO_USE_HASH or the INDEX on SC.  And as I said before, the second alternative I came up with after some further analysis of reducing the column density value seems safer from the perspective of it more directly controlling the desired impact on the execution plan produced.  &#8220;Safe&#8221; is a relative term here, as one way or another we are trying to force the Oracle optimizer to pick a different execution plan to the one it naturally believes is &#8220;best&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40737</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 12:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40737</guid>
		<description><![CDATA[John,

I have to say that I am a little surprised that your hints did work - which (exact) version of Oracle are you using, by the way, because the &quot;unparse&quot; line in your trace file means it&#039;s not the same as the one I was testing on.

In principle a hint like operation(object) &lt;em&gt;ought to be a&lt;/em&gt; short hand for operation(@current_query_block object@current_query_block), so your use_nl(t2) should have been interpreted as use_nl(@sel$1 t2@sel$1) because the location of the hint is in the query block with the default name of sel$1.

I have emphasised the &quot;ought to be&quot; because I don&#039;t know if that claim is true - it&#039;s my working hypothesis, but I haven&#039;t seen anything in the manuals or on Metalink that makes this statement.

If I am correct, two of your hints ought to be invalid because they demand a join method in a query block with only one table, and one ought to be invalid because it references an object that does not exist in that block.

You were correct to ignore the observation someone had made about the hash join being a semi-join, the hints dictate the join method whether the specific case is &quot;normal&quot;, semi or anti.

I wasn&#039;t planning to say anything about getting the best plan for this query - it&#039;s always down to volume, distribution, and available indexes - but there&#039;s always the generality that when the optimizer gives you a hash join when you want a nested loop, it&#039;s probably about the cardinality estimates or the precision of the available indexes, so adjusting some statistics (in a truthful type of way) to tell Oracle that it&#039;s a small volume of data or that there&#039;s a really precise good can be a very good strategy. 

In fact, in one of the models I created for this statement, all I had to do was put the correct index hint into the subquery (although I could have done the same by hinting from the main query) to make Oracle use that index. The optimizer decided that the cheapest path using that index was the nested loop semi-join.  (If anyone did that - and no more - on a production system, though, I&#039;d point out that they had emporarily got the right plan by accident.)



]]></description>
		<content:encoded><![CDATA[<p>John,</p>
<p>I have to say that I am a little surprised that your hints did work &#8211; which (exact) version of Oracle are you using, by the way, because the &#8220;unparse&#8221; line in your trace file means it&#8217;s not the same as the one I was testing on.</p>
<p>In principle a hint like operation(object) <em>ought to be a</em> short hand for operation(@current_query_block object@current_query_block), so your use_nl(t2) should have been interpreted as use_nl(@sel$1 t2@sel$1) because the location of the hint is in the query block with the default name of sel$1.</p>
<p>I have emphasised the &#8220;ought to be&#8221; because I don&#8217;t know if that claim is true &#8211; it&#8217;s my working hypothesis, but I haven&#8217;t seen anything in the manuals or on Metalink that makes this statement.</p>
<p>If I am correct, two of your hints ought to be invalid because they demand a join method in a query block with only one table, and one ought to be invalid because it references an object that does not exist in that block.</p>
<p>You were correct to ignore the observation someone had made about the hash join being a semi-join, the hints dictate the join method whether the specific case is &#8220;normal&#8221;, semi or anti.</p>
<p>I wasn&#8217;t planning to say anything about getting the best plan for this query &#8211; it&#8217;s always down to volume, distribution, and available indexes &#8211; but there&#8217;s always the generality that when the optimizer gives you a hash join when you want a nested loop, it&#8217;s probably about the cardinality estimates or the precision of the available indexes, so adjusting some statistics (in a truthful type of way) to tell Oracle that it&#8217;s a small volume of data or that there&#8217;s a really precise good can be a very good strategy. </p>
<p>In fact, in one of the models I created for this statement, all I had to do was put the correct index hint into the subquery (although I could have done the same by hinting from the main query) to make Oracle use that index. The optimizer decided that the cheapest path using that index was the nested loop semi-join.  (If anyone did that &#8211; and no more &#8211; on a production system, though, I&#8217;d point out that they had emporarily got the right plan by accident.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Brady</title>
		<link>http://jonathanlewis.wordpress.com/2011/06/08/how-to-hint-1/#comment-40736</link>
		<dc:creator><![CDATA[John Brady]]></dc:creator>
		<pubDate>Fri, 10 Jun 2011 11:53:33 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=6467#comment-40736</guid>
		<description><![CDATA[Pavol - I cannot reply to your reply, so I&#039;m replying to mine instead, if you see what I mean.

I also think I may have misunderstood a bit your original reply - its clear from re-reading your replies that you do know about hints and how they work.

I think the USE_NL(C2) should be used by the optimizer for the following reasons:

1. The 10053 trace file showed that the query was being rewritten as a join between the two aliases of the table.
[code]
*****************************
Cost-Based Subquery Unnesting
*****************************
SU: No subqueries to consider in query block SEL$2 (#2).
SU: Considering subquery unnesting in query block SEL$1 (#1)
SU: Performing unnesting that does not require costing.
SU: Considering subquery unnest on SEL$1 (#1).
SU:   Checking validity of unnesting subquery SEL$2 (#2)
SU:   Passed validity checks.
SU:   Transforming EXISTS subquery to a join.
Registered qb: SEL$5DA710D3 0x7dc108e0 (SUBQUERY UNNEST SEL$1; SEL$2)
  signature (): qb_name=SEL$5DA710D3 nbfros=2 flg=0
    fro(0): flg=0 objn=xxx hint_alias=&quot;SC&quot;@&quot;SEL$1&quot;
    fro(1): flg=0 objn=xxx hint_alias=&quot;C2&quot;@&quot;SEL$2&quot;
[/code]
The last line of comments prefixed &quot;SU&quot; states that it has transformed the EXISTS to a join instead.

Later on in the 10053 file it has:
[code]
SQL:******* UNPARSED QUERY IS *******
SELECT ... FROM &quot;SCHEMA&quot;.&quot;SSCLASS&quot; &quot;C2&quot;, &quot;SCHEMA&quot;.&quot;SSCLASS&quot; &quot;SC&quot; 
WHERE ... AND &quot;C2&quot;.&quot;SSCID&quot; = &quot;SC&quot;.&quot;SSCID&quot; AND &quot;C2&quot;.&quot;AUDATE&quot; &gt;= TO_DATE ...
[/code]
So again I read this as saying that the sub-query had been unnested into a join.

2. The reported bad execution plan has a JOIN in it, though it is a SEMI JOIN
3. The hints reported in the outline in the 10053 trace file referred to &quot;USE_HASH (@SEL$5DA710D3 C2@SEL$2)&quot;, from which I infer that a USE_HASH hint was controlling the join between the two data sets, so a join was occurring
4. All of the references to the 2 table aliases in the hints in the outline are prefixed by @SEL$5DA710D3 as the first argument.  These include hints of OUTLINE_LEAF, INDEX, LEADING, USE_HASH and SWAP_JOIN_INPUTS.  So all references were within the same single top level query block.

This lead me to believe that I did not need to qualify the C2 reference in the USE_NL hint by a query block name.  I&#039;m not saying that &quot;I know the USE_NL hint is correct&quot;, but instead that &quot;I believe it would work&quot;.  Generally I do avoid hints because of the dangers of them not quite working the way you want them to, for one reason or another.  In this case I am saying that this was the set of evidence I considered when deciding that a hint of &quot;USE_NL (C2)&quot; and others would be right and would be applied by the optimizer.  But I have no direct evidence that that specific hint was recognised and applied by the optimizer, only that the execution plan used was that desired after the 4 hints were added to the SQL.

I do concede that the reference to C2 in the optimizer produced USE_HASH has @SEL$2 after it, which I take to be the nested sub-query, because the SC references are qualified by @SEL$1.  I don&#039;t know how this affects the meaning of the reference to C2 in either the USE_HASH or USE_NL hints.]]></description>
		<content:encoded><![CDATA[<p>Pavol &#8211; I cannot reply to your reply, so I&#8217;m replying to mine instead, if you see what I mean.</p>
<p>I also think I may have misunderstood a bit your original reply &#8211; its clear from re-reading your replies that you do know about hints and how they work.</p>
<p>I think the USE_NL(C2) should be used by the optimizer for the following reasons:</p>
<p>1. The 10053 trace file showed that the query was being rewritten as a join between the two aliases of the table.</p>
<pre class="brush: plain; title: ; notranslate">
*****************************
Cost-Based Subquery Unnesting
*****************************
SU: No subqueries to consider in query block SEL$2 (#2).
SU: Considering subquery unnesting in query block SEL$1 (#1)
SU: Performing unnesting that does not require costing.
SU: Considering subquery unnest on SEL$1 (#1).
SU:   Checking validity of unnesting subquery SEL$2 (#2)
SU:   Passed validity checks.
SU:   Transforming EXISTS subquery to a join.
Registered qb: SEL$5DA710D3 0x7dc108e0 (SUBQUERY UNNEST SEL$1; SEL$2)
  signature (): qb_name=SEL$5DA710D3 nbfros=2 flg=0
    fro(0): flg=0 objn=xxx hint_alias=&quot;SC&quot;@&quot;SEL$1&quot;
    fro(1): flg=0 objn=xxx hint_alias=&quot;C2&quot;@&quot;SEL$2&quot;
</pre>
<p>The last line of comments prefixed &#8220;SU&#8221; states that it has transformed the EXISTS to a join instead.</p>
<p>Later on in the 10053 file it has:</p>
<pre class="brush: plain; title: ; notranslate">
SQL:******* UNPARSED QUERY IS *******
SELECT ... FROM &quot;SCHEMA&quot;.&quot;SSCLASS&quot; &quot;C2&quot;, &quot;SCHEMA&quot;.&quot;SSCLASS&quot; &quot;SC&quot; 
WHERE ... AND &quot;C2&quot;.&quot;SSCID&quot; = &quot;SC&quot;.&quot;SSCID&quot; AND &quot;C2&quot;.&quot;AUDATE&quot; &gt;= TO_DATE ...
</pre>
<p>So again I read this as saying that the sub-query had been unnested into a join.</p>
<p>2. The reported bad execution plan has a JOIN in it, though it is a SEMI JOIN<br />
3. The hints reported in the outline in the 10053 trace file referred to &#8220;USE_HASH (@SEL$5DA710D3 C2@SEL$2)&#8221;, from which I infer that a USE_HASH hint was controlling the join between the two data sets, so a join was occurring<br />
4. All of the references to the 2 table aliases in the hints in the outline are prefixed by @SEL$5DA710D3 as the first argument.  These include hints of OUTLINE_LEAF, INDEX, LEADING, USE_HASH and SWAP_JOIN_INPUTS.  So all references were within the same single top level query block.</p>
<p>This lead me to believe that I did not need to qualify the C2 reference in the USE_NL hint by a query block name.  I&#8217;m not saying that &#8220;I know the USE_NL hint is correct&#8221;, but instead that &#8220;I believe it would work&#8221;.  Generally I do avoid hints because of the dangers of them not quite working the way you want them to, for one reason or another.  In this case I am saying that this was the set of evidence I considered when deciding that a hint of &#8220;USE_NL (C2)&#8221; and others would be right and would be applied by the optimizer.  But I have no direct evidence that that specific hint was recognised and applied by the optimizer, only that the execution plan used was that desired after the 4 hints were added to the SQL.</p>
<p>I do concede that the reference to C2 in the optimizer produced USE_HASH has @SEL$2 after it, which I take to be the nested sub-query, because the SC references are qualified by @SEL$1.  I don&#8217;t know how this affects the meaning of the reference to C2 in either the USE_HASH or USE_NL hints.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
