<?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: Index Hash</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2012/01/30/index-hash/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Tue, 18 Jun 2013 17:11:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-50638</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Thu, 04 Oct 2012 14:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-50638</guid>
		<description><![CDATA[Yes, the issue is with the names - when {name of index for &quot;c&quot;}  &lt; {name of index for &quot;b&quot;} - plan is Ok :-)]]></description>
		<content:encoded><![CDATA[<p>Yes, the issue is with the names &#8211; when {name of index for &#8220;c&#8221;}  &lt; {name of index for &quot;b&quot;} &#8211; plan is Ok :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-50633</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 04 Oct 2012 14:31:13 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-50633</guid>
		<description><![CDATA[Valentin,
Very strange - I may look at that on the plane home.
Can you affect the plan by changing the names of the indexes so that sorting by name lists them in a different order ?]]></description>
		<content:encoded><![CDATA[<p>Valentin,<br />
Very strange &#8211; I may look at that on the plane home.<br />
Can you affect the plan by changing the names of the indexes so that sorting by name lists them in a different order ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-50630</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Thu, 04 Oct 2012 10:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-50630</guid>
		<description><![CDATA[I&#039;ve found the funny situation when CBO uses one unnecessary index to get 3 columns by index join. I haven&#039;t dug it too deep, just send the pure testcase :
[sourcecode language=&quot;SQL&quot;]
-- drop table t033 purge;
create table t033 (a not null, b not null, c not null, xxx) as 
select level, level, level, lpad(&#039;x&#039;,1000,&#039;x&#039;) from dual connect by level &lt;= 1e4;
create index i033_b on t033(b);
create index i033_a_b on t033(a, b);
create index i033_c on t033(c);
exec dbms_stats.gather_table_stats(user, &#039;t033&#039;, estimate_percent =&gt; 100, cascade =&gt; true)
explain plan for select a,b,c from t033;
select * from table(dbms_xplan.display);
[/sourcecode]
[sourcecode language=&quot;SQL&quot; collapse=&quot;true&quot;]
Plan hash value: 3894408680
 
--------------------------------------------------------------------------------------------
&#124; Id  &#124; Operation               &#124; Name             &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT        &#124;                  &#124; 10000 &#124;   117K&#124;    96   (3)&#124; 00:00:02 &#124;
&#124;   1 &#124;  VIEW                   &#124; index$_join$_001 &#124; 10000 &#124;   117K&#124;    96   (3)&#124; 00:00:02 &#124;
&#124;*  2 &#124;   HASH JOIN             &#124;                  &#124;       &#124;       &#124;            &#124;          &#124;
&#124;*  3 &#124;    HASH JOIN            &#124;                  &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   4 &#124;     INDEX FAST FULL SCAN&#124; I033_B           &#124; 10000 &#124;   117K&#124;    28   (0)&#124; 00:00:01 &#124;
&#124;   5 &#124;     INDEX FAST FULL SCAN&#124; I033_A_B         &#124; 10000 &#124;   117K&#124;    35   (0)&#124; 00:00:01 &#124;
&#124;   6 &#124;    INDEX FAST FULL SCAN &#124; I033_C           &#124; 10000 &#124;   117K&#124;    28   (0)&#124; 00:00:01 &#124;
--------------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   2 - access(ROWID=ROWID)
   3 - access(ROWID=ROWID)
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve found the funny situation when CBO uses one unnecessary index to get 3 columns by index join. I haven&#8217;t dug it too deep, just send the pure testcase :</p>
<pre class="brush: sql; title: ; notranslate">
-- drop table t033 purge;
create table t033 (a not null, b not null, c not null, xxx) as 
select level, level, level, lpad('x',1000,'x') from dual connect by level &lt;= 1e4;
create index i033_b on t033(b);
create index i033_a_b on t033(a, b);
create index i033_c on t033(c);
exec dbms_stats.gather_table_stats(user, 't033', estimate_percent =&gt; 100, cascade =&gt; true)
explain plan for select a,b,c from t033;
select * from table(dbms_xplan.display);
</pre>
<pre class="brush: sql; collapse: true; light: false; title: ; toolbar: true; notranslate">
Plan hash value: 3894408680
 
--------------------------------------------------------------------------------------------
| Id  | Operation               | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |                  | 10000 |   117K|    96   (3)| 00:00:02 |
|   1 |  VIEW                   | index$_join$_001 | 10000 |   117K|    96   (3)| 00:00:02 |
|*  2 |   HASH JOIN             |                  |       |       |            |          |
|*  3 |    HASH JOIN            |                  |       |       |            |          |
|   4 |     INDEX FAST FULL SCAN| I033_B           | 10000 |   117K|    28   (0)| 00:00:01 |
|   5 |     INDEX FAST FULL SCAN| I033_A_B         | 10000 |   117K|    35   (0)| 00:00:01 |
|   6 |    INDEX FAST FULL SCAN | I033_C           | 10000 |   117K|    28   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
 
   2 - access(ROWID=ROWID)
   3 - access(ROWID=ROWID)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44799</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 31 Jan 2012 09:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44799</guid>
		<description><![CDATA[Valentin,

True; and this is just a general case of persuading Oracle that visiting a table many times is cheaper than visiting it once - provided the many visits don&#039;t actually get as far as the table.  I prefer use an inline view - often with a &lt;em&gt;&lt;strong&gt;no_merge hint&lt;/strong&gt;&lt;/em&gt; - to stabilise the effect in more &lt;a href=&quot;http://jonathanlewis.wordpress.com/2010/11/26/index-join-2/&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;&lt;strong&gt;complex examples&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;.


Rather than setting the hidden parameter, there&#039;s a hint (possibly not documented, though) that &lt;a href=&quot;http://jonathanlewis.wordpress.com/2010/05/18/double-trouble/#comment-36264&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;&lt;strong&gt;came up in the comments&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt; of another posting I did on the same topic.]]></description>
		<content:encoded><![CDATA[<p>Valentin,</p>
<p>True; and this is just a general case of persuading Oracle that visiting a table many times is cheaper than visiting it once &#8211; provided the many visits don&#8217;t actually get as far as the table.  I prefer use an inline view &#8211; often with a <em><strong>no_merge hint</strong></em> &#8211; to stabilise the effect in more <a href="http://jonathanlewis.wordpress.com/2010/11/26/index-join-2/" rel="nofollow"><em><strong>complex examples</strong></em></a>.</p>
<p>Rather than setting the hidden parameter, there&#8217;s a hint (possibly not documented, though) that <a href="http://jonathanlewis.wordpress.com/2010/05/18/double-trouble/#comment-36264" rel="nofollow"><em><strong>came up in the comments</strong></em></a> of another posting I did on the same topic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44781</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 22:25:52 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44781</guid>
		<description><![CDATA[Until 11.2 it was possible to use the following analog of IJ:

[sourcecode language=&quot;SQL&quot;]explain plan for
select sum(b.id)
from t1 a, t1 b
where a.rowid = b.rowid
  and a.flag = 0;
select * from table(dbms_xplan.display);

------------------------------------------------------------------
&#124; Id  &#124; Operation              &#124; Name    &#124; Rows  &#124; Bytes &#124; Cost  &#124;
------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT       &#124;         &#124;     1 &#124;    32 &#124;    41 &#124;
&#124;   1 &#124;  SORT AGGREGATE        &#124;         &#124;     1 &#124;    32 &#124;       &#124;
&#124;*  2 &#124;   HASH JOIN            &#124;         &#124;  5000 &#124;   156K&#124;    41 &#124;
&#124;*  3 &#124;    INDEX RANGE SCAN    &#124; T1_FLAG &#124;  5000 &#124; 75000 &#124;    10 &#124;
&#124;   4 &#124;    INDEX FAST FULL SCAN&#124; T1_PK   &#124;   100K&#124;  1660K&#124;    23 &#124;
------------------------------------------------------------------
[/sourcecode]

But from 11.2 CBO can eliminate join by rowid, and add ROWID IS NOT NULL predicate preventing consideration of IJ.
Thus without _optimizer_join_elimination_enabled = false for the same query plan will be:

[sourcecode language=&quot;SQL&quot;]
-----------------------------------------------------------
&#124; Id  &#124; Operation          &#124; Name &#124; Rows  &#124; Bytes &#124; Cost  &#124;
-----------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT   &#124;      &#124;     1 &#124;    20 &#124;   387 &#124;
&#124;   1 &#124;  SORT AGGREGATE    &#124;      &#124;     1 &#124;    20 &#124;       &#124;
&#124;*  2 &#124;   TABLE ACCESS FULL&#124; T1   &#124;  5000 &#124;    97K&#124;   387 &#124;
-----------------------------------------------------------
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Until 11.2 it was possible to use the following analog of IJ:</p>
<pre class="brush: sql; title: ; notranslate">explain plan for
select sum(b.id)
from t1 a, t1 b
where a.rowid = b.rowid
  and a.flag = 0;
select * from table(dbms_xplan.display);

------------------------------------------------------------------
| Id  | Operation              | Name    | Rows  | Bytes | Cost  |
------------------------------------------------------------------
|   0 | SELECT STATEMENT       |         |     1 |    32 |    41 |
|   1 |  SORT AGGREGATE        |         |     1 |    32 |       |
|*  2 |   HASH JOIN            |         |  5000 |   156K|    41 |
|*  3 |    INDEX RANGE SCAN    | T1_FLAG |  5000 | 75000 |    10 |
|   4 |    INDEX FAST FULL SCAN| T1_PK   |   100K|  1660K|    23 |
------------------------------------------------------------------
</pre>
<p>But from 11.2 CBO can eliminate join by rowid, and add ROWID IS NOT NULL predicate preventing consideration of IJ.<br />
Thus without _optimizer_join_elimination_enabled = false for the same query plan will be:</p>
<pre class="brush: sql; title: ; notranslate">
-----------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost  |
-----------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |    20 |   387 |
|   1 |  SORT AGGREGATE    |      |     1 |    20 |       |
|*  2 |   TABLE ACCESS FULL| T1   |  5000 |    97K|   387 |
-----------------------------------------------------------
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44780</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 21:46:48 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44780</guid>
		<description><![CDATA[Valentin,
Fascinating - 9.2.0.6 and July 2006, and &quot;84 - Closed, not feasible to fix&quot; !

It&#039;s just occured to me that I&#039;ve pointed out other bugs with the index hash join earlier http://jonathanlewis.wordpress.com/2010/11/22/index-join/ - I&#039;m a little disappointed that I didn&#039;t notice this one when writing CBO-Fundamentals.
]]></description>
		<content:encoded><![CDATA[<p>Valentin,<br />
Fascinating &#8211; 9.2.0.6 and July 2006, and &#8220;84 &#8211; Closed, not feasible to fix&#8221; !</p>
<p>It&#8217;s just occured to me that I&#8217;ve pointed out other bugs with the index hash join earlier <a href="http://jonathanlewis.wordpress.com/2010/11/22/index-join/" rel="nofollow">http://jonathanlewis.wordpress.com/2010/11/22/index-join/</a> &#8211; I&#8217;m a little disappointed that I didn&#8217;t notice this one when writing CBO-Fundamentals.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44779</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 21:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44779</guid>
		<description><![CDATA[Mladen,

Since it&#039;s not documented my interpretation is, inevitably, a guess.
When you write a query it consists of one or more query blocks (essentially each appearance of the words select, insert, update, delete, merge, introduces a new query block). Your original query blocks appear in the outline text with the label outline(). THe optimizer then transforms the query, possibly in many different ways, to see which cost-based query transformation gives it the best plan. The transformation mechanism may result in a completely different set of query blocks being the things ultimately optimised - these query blocks appear with the lable outline_leaf().]]></description>
		<content:encoded><![CDATA[<p>Mladen,</p>
<p>Since it&#8217;s not documented my interpretation is, inevitably, a guess.<br />
When you write a query it consists of one or more query blocks (essentially each appearance of the words select, insert, update, delete, merge, introduces a new query block). Your original query blocks appear in the outline text with the label outline(). THe optimizer then transforms the query, possibly in many different ways, to see which cost-based query transformation gives it the best plan. The transformation mechanism may result in a completely different set of query blocks being the things ultimately optimised &#8211; these query blocks appear with the lable outline_leaf().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44778</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 21:25:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44778</guid>
		<description><![CDATA[Valentin,

I see you&#039;ve worked out why your results didn&#039;t match mine. 
Your CPU costing values have kicked in, giving the full scan and fast full scans much higher prices, and just tipping your example into the table scan.
The most significant comparison, of course, is between the simple fast full scan and fast full scan as it appears in the join.]]></description>
		<content:encoded><![CDATA[<p>Valentin,</p>
<p>I see you&#8217;ve worked out why your results didn&#8217;t match mine.<br />
Your CPU costing values have kicked in, giving the full scan and fast full scans much higher prices, and just tipping your example into the table scan.<br />
The most significant comparison, of course, is between the simple fast full scan and fast full scan as it appears in the join.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44777</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 21:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44777</guid>
		<description><![CDATA[Lester,

Thnks, you&#039;re right.
Now corrected.]]></description>
		<content:encoded><![CDATA[<p>Lester,</p>
<p>Thnks, you&#8217;re right.<br />
Now corrected.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mladen Gogala</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comment-44776</link>
		<dc:creator><![CDATA[Mladen Gogala]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 20:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178#comment-44776</guid>
		<description><![CDATA[Jonathan, what is the hint OUTLINE_LEAF? The hint itself is undocumented and I was unable to find any definition.]]></description>
		<content:encoded><![CDATA[<p>Jonathan, what is the hint OUTLINE_LEAF? The hint itself is undocumented and I was unable to find any definition.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
