<?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: ANSI Outer</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Sat, 18 May 2013 11:04:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: ANSI Outer 2 &#171; Oracle Scratchpad</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-48014</link>
		<dc:creator><![CDATA[ANSI Outer 2 &#171; Oracle Scratchpad]]></dc:creator>
		<pubDate>Mon, 16 Jul 2012 16:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-48014</guid>
		<description><![CDATA[[...] instead of an index fast full scan. (You&#8217;ll need to set event 22829 &#8211; as shown in this posting &#8211; to check the [...]]]></description>
		<content:encoded><![CDATA[<p>[...] instead of an index fast full scan. (You&#8217;ll need to set event 22829 &#8211; as shown in this posting &#8211; to check the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Part 1: The Hitchhiker&#8217;s Guide to SQL: Lateral derived tables and other alternatives to GROUP BY &#171; So Many Oracle Manuals, So Little Time</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-46107</link>
		<dc:creator><![CDATA[Part 1: The Hitchhiker&#8217;s Guide to SQL: Lateral derived tables and other alternatives to GROUP BY &#171; So Many Oracle Manuals, So Little Time]]></dc:creator>
		<pubDate>Mon, 16 Apr 2012 01:36:56 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-46107</guid>
		<description><![CDATA[[...] solution and followed by window functions, scalar subqueries, and lateral derived tables. Note that event 22829 needs to be set before using lateral derived tables; thanks to Jonathan Lewis for that [...]]]></description>
		<content:encoded><![CDATA[<p>[...] solution and followed by window functions, scalar subqueries, and lateral derived tables. Note that event 22829 needs to be set before using lateral derived tables; thanks to Jonathan Lewis for that [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard Polarski</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-40985</link>
		<dc:creator><![CDATA[Bernard Polarski]]></dc:creator>
		<pubDate>Wed, 13 Jul 2011 07:15:05 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-40985</guid>
		<description><![CDATA[I use to think in rowsets, that is to say, reduce any complex SQL to its sets of rowset over which I apply operators in order to produce the desire output. This leads to the usage of &#039;with v as ..., v1 as ()... &#039; and piling of &#039;select ... from ( ) &#039;. Thought less elegant, it lis a faster delivery method of complex SQL where would-be-lateral are just another rowset to produce and integrate. The downside is rather the optimizer behaviour when the layers piles, however this is balanced by the fact that rowset-building-approach allows a gradual build-and-tune of the query while you are integrating rowset after rowset.]]></description>
		<content:encoded><![CDATA[<p>I use to think in rowsets, that is to say, reduce any complex SQL to its sets of rowset over which I apply operators in order to produce the desire output. This leads to the usage of &#8216;with v as &#8230;, v1 as ()&#8230; &#8216; and piling of &#8216;select &#8230; from ( ) &#8216;. Thought less elegant, it lis a faster delivery method of complex SQL where would-be-lateral are just another rowset to produce and integrate. The downside is rather the optimizer behaviour when the layers piles, however this is balanced by the fact that rowset-building-approach allows a gradual build-and-tune of the query while you are integrating rowset after rowset.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sqlmdx</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-40951</link>
		<dc:creator><![CDATA[sqlmdx]]></dc:creator>
		<pubDate>Thu, 07 Jul 2011 18:23:57 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-40951</guid>
		<description><![CDATA[And another one approach. Just for fun.
[sourcecode]
select
    /*+ gather_plan_statistics */
    t1.id,
    t1.n1,
    t1.v1,
    t2.column_value n1
from
    t1,
    table (
        (
        select
            collect(t2.n1)
        from
            t2
        where
            t1.colx in (7, 11, 13)
        and t2.id = t1.n1
        )
    )(+) t2
where
    t1.id = 15
;
[/sourcecode]
This approach has the same issues as Timur&#039;s one (shown above).
PS. Sorry, but I can&#039;t figure out how to format code in your blog.]]></description>
		<content:encoded><![CDATA[<p>And another one approach. Just for fun.</p>
<pre class="brush: plain; title: ; notranslate">
select
    /*+ gather_plan_statistics */
    t1.id,
    t1.n1,
    t1.v1,
    t2.column_value n1
from
    t1,
    table (
        (
        select
            collect(t2.n1)
        from
            t2
        where
            t1.colx in (7, 11, 13)
        and t2.id = t1.n1
        )
    )(+) t2
where
    t1.id = 15
;
</pre>
<p>This approach has the same issues as Timur&#8217;s one (shown above).<br />
PS. Sorry, but I can&#8217;t figure out how to format code in your blog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sqlmdx</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-40950</link>
		<dc:creator><![CDATA[sqlmdx]]></dc:creator>
		<pubDate>Thu, 07 Jul 2011 18:18:40 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-40950</guid>
		<description><![CDATA[Let me try.
[sourcecode]
alter table t1 add colx number;
update t1 set colx = n1;
commit;
[/sourcecode]
When select statement is written like this
[sourcecode]
select
    t1.id,
    t1.n1,
    t1.v1,
    t2.n1
from
    t1
,
    t2
where
    t1.id = 15
and t2.id(+) = t1.n1
and T1.COLX in (7, 11, 13)
[/sourcecode]
then Oracle treats &quot;T1.COLX in (7, 11, 13)&quot; as post-join predicate and we don&#039;t achieve desirable recordset.

So the main point is: write condition &quot;T1.COLX in (7, 11, 13)&quot; so that Oracle treats it as pre-join predicate:
[sourcecode]
SQL&gt; select
  2      t1.id,
  3      t1.n1,
  4      t1.v1,
  5      t2.n1
  6  from
  7      t1
  8  ,
  9      t2
 10  where
 11      t1.id = 15
 12  and t2.id(+) = t1.n1
 13  and decode(T1.COLX,7,0,11,0,13,0)=nvl2(t2.id(+),0,0);

        ID         N1 V1                 N1
---------- ---------- ---------- ----------
        15         15 0000000015

SQL&gt; select * from table(dbms_xplan.display_cursor(null,null,&#039;ALLSTATS LAST&#039;));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  du7ky61ubqxxv, child number 0
-------------------------------------
select     t1.id,     t1.n1,     t1.v1,     t2.n1 from     t1 ,     t2
where     t1.id = 15 and t2.id(+) = t1.n1 and
decode(T1.COLX,7,0,11,0,13,0)=nvl2(t2.id(+),0,0)

Plan hash value: 3024481811

------------------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name  &#124; Starts &#124; E-Rows &#124; A-Rows &#124;   A-Time   &#124; Buffers &#124;
------------------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;       &#124;      1 &#124;        &#124;      1 &#124;00:00:00.01 &#124;       6 &#124;
&#124;   1 &#124;  NESTED LOOPS OUTER          &#124;       &#124;      1 &#124;      1 &#124;      1 &#124;00:00:00.01 &#124;       6 &#124;
&#124;   2 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;      1 &#124;      1 &#124;      1 &#124;00:00:00.01 &#124;       4 &#124;
&#124;*  3 &#124;    INDEX RANGE SCAN          &#124; T1_I1 &#124;      1 &#124;      1 &#124;      1 &#124;00:00:00.01 &#124;       3 &#124;
&#124;   4 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T2    &#124;      1 &#124;      1 &#124;      0 &#124;00:00:00.01 &#124;       2 &#124;
&#124;*  5 &#124;    INDEX RANGE SCAN          &#124; T2_I1 &#124;      1 &#124;      1 &#124;      0 &#124;00:00:00.01 &#124;       2 &#124;
------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access(&quot;T1&quot;.&quot;ID&quot;=15)
   5 - access(&quot;T2&quot;.&quot;ID&quot;=&quot;T1&quot;.&quot;N1&quot;)
       filter(DECODE(&quot;T1&quot;.&quot;COLX&quot;,7,0,11,0,13,0)=NVL2(&quot;T2&quot;.&quot;ID&quot;,0,0))


26 rows selected.
[/sourcecode]
Of course, the plan is little bit different than yours with &quot;T1.COLX in (7, 11, 13)&quot; condition. But we can see both filter and access predicates. :-)]]></description>
		<content:encoded><![CDATA[<p>Let me try.</p>
<pre class="brush: plain; title: ; notranslate">
alter table t1 add colx number;
update t1 set colx = n1;
commit;
</pre>
<p>When select statement is written like this</p>
<pre class="brush: plain; title: ; notranslate">
select
    t1.id,
    t1.n1,
    t1.v1,
    t2.n1
from
    t1
,
    t2
where
    t1.id = 15
and t2.id(+) = t1.n1
and T1.COLX in (7, 11, 13)
</pre>
<p>then Oracle treats &#8220;T1.COLX in (7, 11, 13)&#8221; as post-join predicate and we don&#8217;t achieve desirable recordset.</p>
<p>So the main point is: write condition &#8220;T1.COLX in (7, 11, 13)&#8221; so that Oracle treats it as pre-join predicate:</p>
<pre class="brush: plain; title: ; notranslate">
SQL&gt; select
  2      t1.id,
  3      t1.n1,
  4      t1.v1,
  5      t2.n1
  6  from
  7      t1
  8  ,
  9      t2
 10  where
 11      t1.id = 15
 12  and t2.id(+) = t1.n1
 13  and decode(T1.COLX,7,0,11,0,13,0)=nvl2(t2.id(+),0,0);

        ID         N1 V1                 N1
---------- ---------- ---------- ----------
        15         15 0000000015

SQL&gt; select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  du7ky61ubqxxv, child number 0
-------------------------------------
select     t1.id,     t1.n1,     t1.v1,     t2.n1 from     t1 ,     t2
where     t1.id = 15 and t2.id(+) = t1.n1 and
decode(T1.COLX,7,0,11,0,13,0)=nvl2(t2.id(+),0,0)

Plan hash value: 3024481811

------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |       |      1 |        |      1 |00:00:00.01 |       6 |
|   1 |  NESTED LOOPS OUTER          |       |      1 |      1 |      1 |00:00:00.01 |       6 |
|   2 |   TABLE ACCESS BY INDEX ROWID| T1    |      1 |      1 |      1 |00:00:00.01 |       4 |
|*  3 |    INDEX RANGE SCAN          | T1_I1 |      1 |      1 |      1 |00:00:00.01 |       3 |
|   4 |   TABLE ACCESS BY INDEX ROWID| T2    |      1 |      1 |      0 |00:00:00.01 |       2 |
|*  5 |    INDEX RANGE SCAN          | T2_I1 |      1 |      1 |      0 |00:00:00.01 |       2 |
------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access(&quot;T1&quot;.&quot;ID&quot;=15)
   5 - access(&quot;T2&quot;.&quot;ID&quot;=&quot;T1&quot;.&quot;N1&quot;)
       filter(DECODE(&quot;T1&quot;.&quot;COLX&quot;,7,0,11,0,13,0)=NVL2(&quot;T2&quot;.&quot;ID&quot;,0,0))


26 rows selected.
</pre>
<p>Of course, the plan is little bit different than yours with &#8220;T1.COLX in (7, 11, 13)&#8221; condition. But we can see both filter and access predicates. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Partitioned Bitmaps &#171; Ukrainian Oracle User Group</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-40930</link>
		<dc:creator><![CDATA[Partitioned Bitmaps &#171; Ukrainian Oracle User Group]]></dc:creator>
		<pubDate>Mon, 04 Jul 2011 21:49:05 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-40930</guid>
		<description><![CDATA[[...] table’s metadata to the table by partition identifier – except you would probably need to use a laterval view, which Oracle doesn’t support, and make the partition extended syntax part of the lateral [...]]]></description>
		<content:encoded><![CDATA[<p>[...] table’s metadata to the table by partition identifier – except you would probably need to use a laterval view, which Oracle doesn’t support, and make the partition extended syntax part of the lateral [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Partitioned Bitmaps &#171; Oracle Scratchpad</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-40907</link>
		<dc:creator><![CDATA[Partitioned Bitmaps &#171; Oracle Scratchpad]]></dc:creator>
		<pubDate>Fri, 01 Jul 2011 17:21:31 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-40907</guid>
		<description><![CDATA[[...] metadata to the table by partition identifier &#8211; except you would probably need to use a laterval view, which Oracle doesn&#8217;t support, and make the partition extended syntax part of the lateral [...]]]></description>
		<content:encoded><![CDATA[<p>[...] metadata to the table by partition identifier &#8211; except you would probably need to use a laterval view, which Oracle doesn&#8217;t support, and make the partition extended syntax part of the lateral [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-39392</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 19:44:49 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-39392</guid>
		<description><![CDATA[Jimmy,

Essentially the optimizer will transform almost any SQL to suit its purposes; ANSI is only slightly special in this respect; but you are right that in effect Oracle transforms from ANSI style to Oracle style before optimising in most cases. As far as I know there are only two classes of ANSI SQL that have a &quot;native optimization&quot; code path - the full outer join and the partitioned outer join.]]></description>
		<content:encoded><![CDATA[<p>Jimmy,</p>
<p>Essentially the optimizer will transform almost any SQL to suit its purposes; ANSI is only slightly special in this respect; but you are right that in effect Oracle transforms from ANSI style to Oracle style before optimising in most cases. As far as I know there are only two classes of ANSI SQL that have a &#8220;native optimization&#8221; code path &#8211; the full outer join and the partitioned outer join.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-39387</link>
		<dc:creator><![CDATA[Jimmy]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 16:10:35 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-39387</guid>
		<description><![CDATA[Correct if I&#039;m wrong. But I have heard that the CBO cannot optimize a query that uses an ANSI Outer Join syntax. The CBO must convert it to Oracle&#039;s outer join syntax before the query can be optimized. Is that correct?]]></description>
		<content:encoded><![CDATA[<p>Correct if I&#8217;m wrong. But I have heard that the CBO cannot optimize a query that uses an ANSI Outer Join syntax. The CBO must convert it to Oracle&#8217;s outer join syntax before the query can be optimized. Is that correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Todor Botev</title>
		<link>http://jonathanlewis.wordpress.com/2011/01/31/ansi-outer/#comment-39386</link>
		<dc:creator><![CDATA[Todor Botev]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 13:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5597#comment-39386</guid>
		<description><![CDATA[Yes, you are right - the solution cannot be applied in a more general case.]]></description>
		<content:encoded><![CDATA[<p>Yes, you are right &#8211; the solution cannot be applied in a more general case.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
