<?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: Quiz Night</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Mon, 20 May 2013 17:10:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: double trouble &#171; Oracle Scratchpad</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36252</link>
		<dc:creator><![CDATA[double trouble &#171; Oracle Scratchpad]]></dc:creator>
		<pubDate>Tue, 18 May 2010 19:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36252</guid>
		<description><![CDATA[[...] Execution plans,Performance,Tuning &#8212; Jonathan Lewis @ 7:06 pm UTC May 18,2010   In the latest Quiz Night, I asked how you could make a query more efficient by changing a two table join into a three table [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Execution plans,Performance,Tuning &#8212; Jonathan Lewis @ 7:06 pm UTC May 18,2010   In the latest Quiz Night, I asked how you could make a query more efficient by changing a two table join into a three table [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36244</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Tue, 18 May 2010 07:38:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36244</guid>
		<description><![CDATA[Yay!

But the predicate alone doesn&#039;t do it: one must also SELECT and ORDER BY t3 fields instead of t1 fields.

Saluti!
Flado]]></description>
		<content:encoded><![CDATA[<p>Yay!</p>
<p>But the predicate alone doesn&#8217;t do it: one must also SELECT and ORDER BY t3 fields instead of t1 fields.</p>
<p>Saluti!<br />
Flado</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36242</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 18 May 2010 07:23:04 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36242</guid>
		<description><![CDATA[Flado,

Your additional predicate is an exact match for the one that will be appearing on the blog  item that I&#039;ll be publishing later on today.]]></description>
		<content:encoded><![CDATA[<p>Flado,</p>
<p>Your additional predicate is an exact match for the one that will be appearing on the blog  item that I&#8217;ll be publishing later on today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36237</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Mon, 17 May 2010 13:41:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36237</guid>
		<description><![CDATA[Something like this?

[sourcecode]
select t3. ... -- what used to come from t1 now comes from t3
from    tableA  t1,
        tableB  t2,
        tableA  t3
where
        t1.filter = ...
and     t2.join = t1.join
and     t2.filter = ...
and     t3.rowid = t1.rowid
order by t3. ... -- ditto
[/sourcecode]

Or am I late to the party?

Cheers!
Flado]]></description>
		<content:encoded><![CDATA[<p>Something like this?</p>
<pre class="brush: plain; title: ; notranslate">
select t3. ... -- what used to come from t1 now comes from t3
from    tableA  t1,
        tableB  t2,
        tableA  t3
where
        t1.filter = ...
and     t2.join = t1.join
and     t2.filter = ...
and     t3.rowid = t1.rowid
order by t3. ... -- ditto
</pre>
<p>Or am I late to the party?</p>
<p>Cheers!<br />
Flado</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36235</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 17 May 2010 07:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36235</guid>
		<description><![CDATA[Gary,

Well done - you&#039;ve put your finger on the critical point.
I haven&#039;t seen Oracle do it yet (but it might be possible in 11.2) but it&#039;s perfectly reasonable to write SQL that visits a table using an index-only access path, and then comes back later by rowid to pick up the table data.  I published an example of this type of approach &lt;a href=&quot;http://jonathanlewis.wordpress.com/2008/04/27/manual-optimisation/&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;&lt;strong&gt;about a year ago&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;, but I&#039;ll post a much simpler (and less contentious) example as soon as I have a few minutes.]]></description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>Well done &#8211; you&#8217;ve put your finger on the critical point.<br />
I haven&#8217;t seen Oracle do it yet (but it might be possible in 11.2) but it&#8217;s perfectly reasonable to write SQL that visits a table using an index-only access path, and then comes back later by rowid to pick up the table data.  I published an example of this type of approach <a href="http://jonathanlewis.wordpress.com/2008/04/27/manual-optimisation/" rel="nofollow"><em><strong>about a year ago</strong></em></a>, but I&#8217;ll post a much simpler (and less contentious) example as soon as I have a few minutes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36230</link>
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Sun, 16 May 2010 23:45:44 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36230</guid>
		<description><![CDATA[My *new improved* thought.
I think the old plan involved a full table scan of tablea hash joined to a full scan from tableb.

I think the new plan involves an index fast full scan on tablea (columns in the t1.join = t2.join) hash joined to a scan from tableb. The results from that join then use a straight ROWID join to get additional data from tablea (eg stuff required for the SELECT but not for the join/where predicates).

The index being full scan would (in this case) be a lot smaller than the table, so the hash join would be more efficient. 

Not sure whether that plan could get chosen by the optimizer without the explicit join.]]></description>
		<content:encoded><![CDATA[<p>My *new improved* thought.<br />
I think the old plan involved a full table scan of tablea hash joined to a full scan from tableb.</p>
<p>I think the new plan involves an index fast full scan on tablea (columns in the t1.join = t2.join) hash joined to a scan from tableb. The results from that join then use a straight ROWID join to get additional data from tablea (eg stuff required for the SELECT but not for the join/where predicates).</p>
<p>The index being full scan would (in this case) be a lot smaller than the table, so the hash join would be more efficient. </p>
<p>Not sure whether that plan could get chosen by the optimizer without the explicit join.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36229</link>
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Sun, 16 May 2010 23:21:53 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36229</guid>
		<description><![CDATA[Interesting if adding an extra &#039;version&#039; of tablea into the FROM clause doesn&#039;t change the result. tablea must be joined on a primary or unique key (otherwise you&#039;d have, at least, the potential for duplicates in the result set). If tablea had a unique key on &#039;colx&#039; then joining tablea to itself on &#039;colx&#039; would be an implicit &#039;colx is not null&#039; condition. If 99% of tablea entries had a null value for &#039;colx&#039; and an index existed on that column (which it would do for a unique key), then the optimizer could use the index to single out that remaining 1%, which might provide a better optimizer path.

So I can see how an extra join may give a more efficient path. But if that was the situation then I&#039;d expect you to have simply added a &#039;colx is not null&#039; predicate.]]></description>
		<content:encoded><![CDATA[<p>Interesting if adding an extra &#8216;version&#8217; of tablea into the FROM clause doesn&#8217;t change the result. tablea must be joined on a primary or unique key (otherwise you&#8217;d have, at least, the potential for duplicates in the result set). If tablea had a unique key on &#8216;colx&#8217; then joining tablea to itself on &#8216;colx&#8217; would be an implicit &#8216;colx is not null&#8217; condition. If 99% of tablea entries had a null value for &#8216;colx&#8217; and an index existed on that column (which it would do for a unique key), then the optimizer could use the index to single out that remaining 1%, which might provide a better optimizer path.</p>
<p>So I can see how an extra join may give a more efficient path. But if that was the situation then I&#8217;d expect you to have simply added a &#8216;colx is not null&#8217; predicate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36217</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 15 May 2010 10:47:45 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36217</guid>
		<description><![CDATA[I&#039;d need something more concrete to go on, but the comment &lt;em&gt;&quot;Depending on the intermediate result set size this may be more efficient.&quot;&lt;/em&gt; highlights an important principle.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;d need something more concrete to go on, but the comment <em>&#8220;Depending on the intermediate result set size this may be more efficient.&#8221;</em> highlights an important principle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36216</link>
		<dc:creator><![CDATA[Jim]]></dc:creator>
		<pubDate>Sat, 15 May 2010 07:43:54 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36216</guid>
		<description><![CDATA[TableA is joined twice here - so maybe this will lead to the use of a HASH JOIN instead of any other join implementation. 

Depending on the intermediate result set size this may be more efficient.

Another option would be that by joining TableA again, an index might be used which will allow to spare additional sort operations.

Any of those guesses in the right playfield?

cheers,
Jim.]]></description>
		<content:encoded><![CDATA[<p>TableA is joined twice here &#8211; so maybe this will lead to the use of a HASH JOIN instead of any other join implementation. </p>
<p>Depending on the intermediate result set size this may be more efficient.</p>
<p>Another option would be that by joining TableA again, an index might be used which will allow to spare additional sort operations.</p>
<p>Any of those guesses in the right playfield?</p>
<p>cheers,<br />
Jim.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/14/quiz-night-5/#comment-36213</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 14 May 2010 20:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3694#comment-36213</guid>
		<description><![CDATA[Timur,

The principle of turning a two-table into a more efficient three-table is the important bit. I hadn&#039;t applied a great deal of thought to whether I would do it with just one more predicate in the framework about - but I think I can construct an example with just one more.]]></description>
		<content:encoded><![CDATA[<p>Timur,</p>
<p>The principle of turning a two-table into a more efficient three-table is the important bit. I hadn&#8217;t applied a great deal of thought to whether I would do it with just one more predicate in the framework about &#8211; but I think I can construct an example with just one more.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
