<?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: First Table is 550MB, Second Table is 26GB – Nested Loops or Full Table Scan? 2</title>
	<atom:link href="http://hoopercharles.wordpress.com/2010/10/02/first-table-is-550mb-second-table-is-26gb-%E2%80%93-nested-loops-or-full-table-scan-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoopercharles.wordpress.com/2010/10/02/first-table-is-550mb-second-table-is-26gb-%e2%80%93-nested-loops-or-full-table-scan-2/</link>
	<description>Miscellaneous Random Oracle Topics: Stop, Think, ... Understand</description>
	<lastBuildDate>Thu, 23 May 2013 04:02:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2010/10/02/first-table-is-550mb-second-table-is-26gb-%e2%80%93-nested-loops-or-full-table-scan-2/#comment-1974</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 04 Oct 2010 13:40:42 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=3405#comment-1974</guid>
		<description><![CDATA[Narendra,

I am not sure that I am in a position to disagree with either Jonathan or Greg regarding that OTN thread.  Their answers are probably better than the answers I would have provided had I joined that thread.

I noticed in that thread you stated &quot;I thought when oracle joins two tables, which are accessed using full table scan, it will always (??) choose hash join (unless explcitly hinted to use Nested Loop).&quot;  In part 4 of this blog article series (and also in this blog article) I showed an unhinted execution plan that showed nested loops and a full table scan, even when suitable indexes existed:
[code]
Plan hash value: 2077217387

---------------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name         &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
---------------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;              &#124;  1000 &#124;   414K&#124;  1085   (1)&#124; 00:00:14 &#124;
&#124;   1 &#124;  NESTED LOOPS                &#124;              &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   2 &#124;   NESTED LOOPS               &#124;              &#124;  1000 &#124;   414K&#124;  1085   (1)&#124; 00:00:14 &#124;
&#124;   3 &#124;    TABLE ACCESS FULL         &#124; T1           &#124; 10000 &#124;  2070K&#124;    84   (0)&#124; 00:00:02 &#124;
&#124;*  4 &#124;    INDEX UNIQUE SCAN         &#124; SYS_C0018300 &#124;     1 &#124;       &#124;     0   (0)&#124; 00:00:01 &#124;
&#124;   5 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T2           &#124;     1 &#124;   212 &#124;     1   (0)&#124; 00:00:01 &#124;
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access(&quot;T1&quot;.&quot;COL1&quot;=&quot;T2&quot;.&quot;COL1&quot;) 
[/code]

The above shows a nested loops join between the &quot;large&quot; table and the primary key index for table T2.

In this blog article we also see another case:
[code]
Plan hash value: 617224274

--------------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name        &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;             &#124;   100 &#124; 42400 &#124;   303   (0)&#124; 00:00:04 &#124;
&#124;   1 &#124;  NESTED LOOPS                &#124;             &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   2 &#124;   NESTED LOOPS               &#124;             &#124;   100 &#124; 42400 &#124;   303   (0)&#124; 00:00:04 &#124;
&#124;   3 &#124;    TABLE ACCESS FULL         &#124; T2          &#124;   100K&#124;    20M&#124;     3   (0)&#124; 00:00:01 &#124;
&#124;*  4 &#124;    INDEX RANGE SCAN          &#124; IND_T1_COL2 &#124;     1 &#124;       &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;   5 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1          &#124;     1 &#124;   212 &#124;     3   (0)&#124; 00:00:01 &#124;
--------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access(&quot;T1&quot;.&quot;COL2&quot;=&quot;T2&quot;.&quot;COL2&quot;)
[/code]

In the above a full table scan is performed on T2 (the small table) and a nested loops operation is performed on an index for table T2 (the large table).

Was there something else in that thread that you found to be interesting?]]></description>
		<content:encoded><![CDATA[<p>Narendra,</p>
<p>I am not sure that I am in a position to disagree with either Jonathan or Greg regarding that OTN thread.  Their answers are probably better than the answers I would have provided had I joined that thread.</p>
<p>I noticed in that thread you stated &#8220;I thought when oracle joins two tables, which are accessed using full table scan, it will always (??) choose hash join (unless explcitly hinted to use Nested Loop).&#8221;  In part 4 of this blog article series (and also in this blog article) I showed an unhinted execution plan that showed nested loops and a full table scan, even when suitable indexes existed:</p>
<pre class="brush: plain; title: ; notranslate">
Plan hash value: 2077217387

---------------------------------------------------------------------------------------------
| Id  | Operation                    | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |              |  1000 |   414K|  1085   (1)| 00:00:14 |
|   1 |  NESTED LOOPS                |              |       |       |            |          |
|   2 |   NESTED LOOPS               |              |  1000 |   414K|  1085   (1)| 00:00:14 |
|   3 |    TABLE ACCESS FULL         | T1           | 10000 |  2070K|    84   (0)| 00:00:02 |
|*  4 |    INDEX UNIQUE SCAN         | SYS_C0018300 |     1 |       |     0   (0)| 00:00:01 |
|   5 |   TABLE ACCESS BY INDEX ROWID| T2           |     1 |   212 |     1   (0)| 00:00:01 |
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access(&quot;T1&quot;.&quot;COL1&quot;=&quot;T2&quot;.&quot;COL1&quot;) 
</pre>
<p>The above shows a nested loops join between the &#8220;large&#8221; table and the primary key index for table T2.</p>
<p>In this blog article we also see another case:</p>
<pre class="brush: plain; title: ; notranslate">
Plan hash value: 617224274

--------------------------------------------------------------------------------------------
| Id  | Operation                    | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |             |   100 | 42400 |   303   (0)| 00:00:04 |
|   1 |  NESTED LOOPS                |             |       |       |            |          |
|   2 |   NESTED LOOPS               |             |   100 | 42400 |   303   (0)| 00:00:04 |
|   3 |    TABLE ACCESS FULL         | T2          |   100K|    20M|     3   (0)| 00:00:01 |
|*  4 |    INDEX RANGE SCAN          | IND_T1_COL2 |     1 |       |     2   (0)| 00:00:01 |
|   5 |   TABLE ACCESS BY INDEX ROWID| T1          |     1 |   212 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access(&quot;T1&quot;.&quot;COL2&quot;=&quot;T2&quot;.&quot;COL2&quot;)
</pre>
<p>In the above a full table scan is performed on T2 (the small table) and a nested loops operation is performed on an index for table T2 (the large table).</p>
<p>Was there something else in that thread that you found to be interesting?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Narendra</title>
		<link>http://hoopercharles.wordpress.com/2010/10/02/first-table-is-550mb-second-table-is-26gb-%e2%80%93-nested-loops-or-full-table-scan-2/#comment-1937</link>
		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Sun, 03 Oct 2010 07:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=3405#comment-1937</guid>
		<description><![CDATA[Charles,

That is a lot of SQL and plans to look at ;)
On a serious note, I am not sure if this is any way related to this topic but this reminded me of a case I saw on forums in the past.
http://forums.oracle.com/forums/thread.jspa?threadID=1015916&amp;start=0&amp;tstart=0
The database version in that case was 10.2.0.4 and I clearly remember that I was able to reproduce OP&#039;s results. Jonathan and Greg have provided some classic answers (as always) there. I am not sure if 11g has &quot;fixed&quot; it (I thought of testing it but a) I did not have enough space on my VM and b) got bored of creating so many daily partitions ;) )]]></description>
		<content:encoded><![CDATA[<p>Charles,</p>
<p>That is a lot of SQL and plans to look at <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
On a serious note, I am not sure if this is any way related to this topic but this reminded me of a case I saw on forums in the past.<br />
<a href="http://forums.oracle.com/forums/thread.jspa?threadID=1015916&#038;start=0&#038;tstart=0" rel="nofollow">http://forums.oracle.com/forums/thread.jspa?threadID=1015916&#038;start=0&#038;tstart=0</a><br />
The database version in that case was 10.2.0.4 and I clearly remember that I was able to reproduce OP&#8217;s results. Jonathan and Greg have provided some classic answers (as always) there. I am not sure if 11g has &#8220;fixed&#8221; it (I thought of testing it but a) I did not have enough space on my VM and b) got bored of creating so many daily partitions <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
]]></content:encoded>
	</item>
</channel>
</rss>
