<?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: Stored outline bug or enhancement? &#8211; Oracle 11g</title>
	<atom:link href="http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/feed/" rel="self" type="application/rss+xml" />
	<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/</link>
	<description>We are natural born scientists</description>
	<lastBuildDate>Fri, 17 Dec 2010 18:43:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Robert Ponder</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-637</link>
		<dc:creator><![CDATA[Robert Ponder]]></dc:creator>
		<pubDate>Mon, 27 Sep 2010 00:09:40 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-637</guid>
		<description><![CDATA[Hi Dion,

Thanks for your response.  It was an Oracle bug.  I don&#039;t recall the exact hint now but I finally found in the outline that the hint was not there.  I did an insert to add it to the outline and everything worked just fine.]]></description>
		<content:encoded><![CDATA[<p>Hi Dion,</p>
<p>Thanks for your response.  It was an Oracle bug.  I don&#8217;t recall the exact hint now but I finally found in the outline that the hint was not there.  I did an insert to add it to the outline and everything worked just fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SANGSEO SEO</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-437</link>
		<dc:creator><![CDATA[SANGSEO SEO]]></dc:creator>
		<pubDate>Mon, 21 Sep 2009 09:43:25 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-437</guid>
		<description><![CDATA[2 days ago,I test this case under the same condition.]Surprisingly,10G and 11G choosed the composite index.

In this test case,The composite index would be acceptible to optimizer.

Everytime I simulate with my brain assuming the composite index consited of c1 and c2.

C1 is very selective condition with the condition of equal.
C2 is not as good as C1.
Imagine .
Let&#039;s suppose that composite index.
------------------------------
C1               C2      rowid
------------------------------
1                 1 
1                 2 
1                 3
.                 .
.                 .
.                 .
.                10000
2                 1
2                 2 
.                 .
.                 1000
3                 1      
3                 2 
3                 3
.                 .
.                 100
4                 1       &lt;--Index scan begin here
4                 2
4                 .
.                 10     &lt;--end  
5                 1
--------------------------------------
All the Optimize have to do is index scan to get Count(*).]]></description>
		<content:encoded><![CDATA[<p>2 days ago,I test this case under the same condition.]Surprisingly,10G and 11G choosed the composite index.</p>
<p>In this test case,The composite index would be acceptible to optimizer.</p>
<p>Everytime I simulate with my brain assuming the composite index consited of c1 and c2.</p>
<p>C1 is very selective condition with the condition of equal.<br />
C2 is not as good as C1.<br />
Imagine .<br />
Let&#8217;s suppose that composite index.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
C1               C2      rowid<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
1                 1<br />
1                 2<br />
1                 3<br />
.                 .<br />
.                 .<br />
.                 .<br />
.                10000<br />
2                 1<br />
2                 2<br />
.                 .<br />
.                 1000<br />
3                 1<br />
3                 2<br />
3                 3<br />
.                 .<br />
.                 100<br />
4                 1       &lt;&#8211;Index scan begin here<br />
4                 2<br />
4                 .<br />
.                 10     &lt;&#8211;end<br />
5                 1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
All the Optimize have to do is index scan to get Count(*).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-397</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Sat, 15 Aug 2009 01:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-397</guid>
		<description><![CDATA[Kerry. 
I was busy on the other stuffs and thanks for the sharing. I would take a careful look at your post.]]></description>
		<content:encoded><![CDATA[<p>Kerry.<br />
I was busy on the other stuffs and thanks for the sharing. I would take a careful look at your post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kerry Osborne</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-396</link>
		<dc:creator><![CDATA[Kerry Osborne]]></dc:creator>
		<pubDate>Fri, 14 Aug 2009 19:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-396</guid>
		<description><![CDATA[Dion, 

  I had a chance to do some investigation on this issue. I did a blog post about it here: 

http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/

This post shows a case where creating an outline on a statement causes it&#039;s execution plan to change. Behavior is the same from 10.2.0.3 to 11.1.0.7. 

Kerry]]></description>
		<content:encoded><![CDATA[<p>Dion, </p>
<p>  I had a chance to do some investigation on this issue. I did a blog post about it here: </p>
<p><a href="http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/" rel="nofollow">http://kerryosborne.oracle-guy.com/2009/07/why-isnt-oracle-using-my-outline-profile-baseline/</a></p>
<p>This post shows a case where creating an outline on a statement causes it&#8217;s execution plan to change. Behavior is the same from 10.2.0.3 to 11.1.0.7. </p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #156: a Carnival of the Vanities for DBAs &#124; Pythian Group Blog</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-371</link>
		<dc:creator><![CDATA[Log Buffer #156: a Carnival of the Vanities for DBAs &#124; Pythian Group Blog]]></dc:creator>
		<pubDate>Fri, 31 Jul 2009 22:32:51 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-371</guid>
		<description><![CDATA[[...] Cho was on another quirk, the stored outline abnormality in Oracle 11g. Bug or enhancement, he wonders, and the readers [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Cho was on another quirk, the stored outline abnormality in Oracle 11g. Bug or enhancement, he wonders, and the readers [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-361</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 21:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-361</guid>
		<description><![CDATA[Kerry.

Thanks for the insight on the INDEX hint problem. I also thought it would be a new INDEX hint convention problem. I edited the outline(ol$hints) by replacing Oracle generated hint to the old fashioned  one - like INDEX(t1 t1_n1)). But the problem still existed. There could be some mistakes while editing outline. 

I would investigate this problem with far more options than I expected this week. :)]]></description>
		<content:encoded><![CDATA[<p>Kerry.</p>
<p>Thanks for the insight on the INDEX hint problem. I also thought it would be a new INDEX hint convention problem. I edited the outline(ol$hints) by replacing Oracle generated hint to the old fashioned  one &#8211; like INDEX(t1 t1_n1)). But the problem still existed. There could be some mistakes while editing outline. </p>
<p>I would investigate this problem with far more options than I expected this week. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kerry Osborne</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-360</link>
		<dc:creator><![CDATA[Kerry Osborne]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 17:29:31 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-360</guid>
		<description><![CDATA[Hi Dion. 

  First off let me say that this is a very interesting post and as usual pretty thought provoking.

  I believe the whole issue revolves around a design decision to start using the newer form of the index hints that don&#039;t specify the name of the index. So the hint uses the form INDEX(TABLE_NAME COLUMN_NAME) as opposed to the older more specific format INDEX(TABLE_NAME INDEX_NAME). I&#039;m not sure when the newer format became available (I think in 10 but maybe in 9). At any rate, the non-specific format leaves it to the optimizers discretion as to which index to use. This means that the plan can change, even though the outline is being used. While I&#039;m sure the developers had their reasons, it seems a bad design choice considering that outlines were invented to help improve stability of plans by giving the optimizer few if any choices. 

  This is not an 11g specific issue by the way, as the same behavior exists in 10.2. And it is not specific to Outlines either as it is also an issue with SQL Profiles and Baselines. As an aside, the form of the index hint is not always the non-specific version either. Even in 11.1.0.7, the specific format shows up. I have not tried to figure out how it decides to pick one format or the other (something to look at next time I get bored I guess).  

Kerry]]></description>
		<content:encoded><![CDATA[<p>Hi Dion. </p>
<p>  First off let me say that this is a very interesting post and as usual pretty thought provoking.</p>
<p>  I believe the whole issue revolves around a design decision to start using the newer form of the index hints that don&#8217;t specify the name of the index. So the hint uses the form INDEX(TABLE_NAME COLUMN_NAME) as opposed to the older more specific format INDEX(TABLE_NAME INDEX_NAME). I&#8217;m not sure when the newer format became available (I think in 10 but maybe in 9). At any rate, the non-specific format leaves it to the optimizers discretion as to which index to use. This means that the plan can change, even though the outline is being used. While I&#8217;m sure the developers had their reasons, it seems a bad design choice considering that outlines were invented to help improve stability of plans by giving the optimizer few if any choices. </p>
<p>  This is not an 11g specific issue by the way, as the same behavior exists in 10.2. And it is not specific to Outlines either as it is also an issue with SQL Profiles and Baselines. As an aside, the form of the index hint is not always the non-specific version either. Even in 11.1.0.7, the specific format shows up. I have not tried to figure out how it decides to pick one format or the other (something to look at next time I get bored I guess).  </p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-358</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 07:06:11 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-358</guid>
		<description><![CDATA[@Greg

Thanks for the test case. You did what I should have done already. 
(I have no access to 11.1.0.7 right now, but let me check it tomorrow)

And your last advice made me realize that I should be more careful when posting article. The online writing sometimes makes me forget the fact that I&#039;m not just writing something, but trying to contribute to the Oracle commnuity.

PS) I edited your test case to use &lt;b&gt;sourcecode&lt;/b&gt; tag because &lt;pre&gt; tag has formatting problems with &lt;b&gt;&lt;&lt;/b&gt; character.]]></description>
		<content:encoded><![CDATA[<p>@Greg</p>
<p>Thanks for the test case. You did what I should have done already.<br />
(I have no access to 11.1.0.7 right now, but let me check it tomorrow)</p>
<p>And your last advice made me realize that I should be more careful when posting article. The online writing sometimes makes me forget the fact that I&#8217;m not just writing something, but trying to contribute to the Oracle commnuity.</p>
<p>PS) I edited your test case to use <b>sourcecode</b> tag because &lt;pre&gt; tag has formatting problems with <b>&lt;</b> character.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Rahn</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-357</link>
		<dc:creator><![CDATA[Greg Rahn]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 05:35:03 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-357</guid>
		<description><![CDATA[Looks like a bug (not an enhancement) that exists in 11.1.0.6 and is already fixed in 11.1.0.7.

[sourcecode language=&#039;sql&#039;]
SQL&gt; select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
CORE    11.1.0.7.0      Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production

SQL&gt; create table t1(c1 int, c2 int);

Table created.

SQL&gt; -- c1 = skewed, c2 = normal
SQL&gt; insert into t1
  2  select 1, level
  3  from dual
  4  connect by level &lt;= 10000
  5  union all
  6  select 2, level
  7  from dual
  8  connect by level &lt;= 1000
  9  union all
 10  select 3, level
 11  from dual
 12  connect by level &lt;= 100
 13  union all
 14  select 4, level
 15  from dual
 16  connect by level &lt;= 10
 17  union all
 18  select 5, level
 19  from dual
 20  connect by level  &lt;= 1;

SQL&gt; commit;

Commit complete.

SQL&gt; create index t1_n1 on t1(c1);

Index created.

SQL&gt; create index t1_n2 on t1(c2);

Index created.

SQL&gt; exec dbms_stats.gather_table_stats(user, &#039;t1&#039;, method_opt =&gt; &#039;for columns c1 size skewonly&#039;);

PL/SQL procedure successfully completed.

SQL&gt; explain plan for
  2  select count(*)
  3  from t1
  4  where c1 = 4
  5  and c2 between 1 and 10;

Explained.

SQL&gt; select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
Plan hash value: 359681750

--------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name  &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;       &#124;     1 &#124;     6 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;   1 &#124;  SORT AGGREGATE              &#124;       &#124;     1 &#124;     6 &#124;            &#124;          &#124;
&#124;*  2 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;     1 &#124;     6 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;*  3 &#124;    INDEX RANGE SCAN          &#124; T1_N1 &#124;    10 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(&quot;C2&quot;&gt;=1 AND &quot;C2&quot; ...

  1 SQL&gt; create or replace outline test_outln4
  2  on
  3  select count(*)
  4  from t1
  5  where c1 = 4
  6  and c2 between 1 and 10;

Outline created.

SQL&gt; alter session set use_stored_outlines = true;

Session altered.

SQL&gt; select hint from user_outline_hints
  2  where name = &#039;TEST_OUTLN4&#039;;

HINT
--------------------------------------------------------------------------------
INDEX_RS_ASC(@&quot;SEL$1&quot; &quot;T1&quot;@&quot;SEL$1&quot; (&quot;T1&quot;.&quot;C1&quot;))
OUTLINE_LEAF(@&quot;SEL$1&quot;)
ALL_ROWS
DB_VERSION(&#039;11.1.0.7&#039;)
OPTIMIZER_FEATURES_ENABLE(&#039;11.1.0.7&#039;)
IGNORE_OPTIM_EMBEDDED_HINTS

SQL&gt; create index t1_n3 on t1(c1, c2);

Index created.

SQL&gt; explain plan for
  2  select count(*)
  3  from t1
  4  where c1 = 4
  5  and c2 between 1 and 10;

Explained.

SQL&gt; select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
Plan hash value: 359681750

--------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name  &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;       &#124;     1 &#124;     6 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;   1 &#124;  SORT AGGREGATE              &#124;       &#124;     1 &#124;     6 &#124;            &#124;          &#124;
&#124;*  2 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;     1 &#124;     6 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;*  3 &#124;    INDEX RANGE SCAN          &#124; T1_N1 &#124;    10 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(&quot;C2&quot;&gt;=1 AND &quot;C2&quot; select count(*)
  
  1 SQL&gt; select count(*)
  2  from t1
  3  where c1 = 4
  4  and c2 between 1 and 10;

  COUNT(*)
----------
        10

SQL&gt; select * from table(dbms_xplan.display_cursor(format=&gt;&#039;+outline&#039;));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
SQL_ID  0p19ucnnf9zpw, child number 0
-------------------------------------
select count(*) from t1 where c1 = 4 and c2 between 1 and 10

Plan hash value: 359681750

--------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name  &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;       &#124;       &#124;       &#124;     2 (100)&#124;          &#124;
&#124;   1 &#124;  SORT AGGREGATE              &#124;       &#124;     1 &#124;     6 &#124;            &#124;          &#124;
&#124;*  2 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;     1 &#124;     6 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;*  3 &#124;    INDEX RANGE SCAN          &#124; T1_N1 &#124;    10 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
--------------------------------------------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE(&#039;11.1.0.7&#039;)
      DB_VERSION(&#039;11.1.0.7&#039;)
      ALL_ROWS
      OUTLINE_LEAF(@&quot;SEL$1&quot;)
      INDEX_RS_ASC(@&quot;SEL$1&quot; &quot;T1&quot;@&quot;SEL$1&quot; (&quot;T1&quot;.&quot;C1&quot;))
      END_OUTLINE_DATA
  */

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter((&quot;C2&quot;&gt;=1 AND &quot;C2&quot; 

SQL&gt; select count(*)alter session set use_stored_outlines = false;

Session altered.

SQL&gt; select count(*)
  2  from t1
  3  where c1 = 4
  4  and c2 between 1 and 10;

  COUNT(*)
----------
        10

SQL&gt; select * from table(dbms_xplan.display_cursor(format=&gt;&#039;+outline&#039;));

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------
SQL_ID  0p19ucnnf9zpw, child number 1
-------------------------------------
select count(*) from t1 where c1 = 4 and c2 between 1 and 10

Plan hash value: 3096360861

---------------------------------------------------------------------------
&#124; Id  &#124; Operation         &#124; Name  &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
---------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT  &#124;       &#124;       &#124;       &#124;     1 (100)&#124;          &#124;
&#124;   1 &#124;  SORT AGGREGATE   &#124;       &#124;     1 &#124;     6 &#124;            &#124;          &#124;
&#124;*  2 &#124;   INDEX RANGE SCAN&#124; T1_N3 &#124;     1 &#124;     6 &#124;     1   (0)&#124; 00:00:01 &#124;
---------------------------------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE(&#039;11.1.0.7&#039;)
      DB_VERSION(&#039;11.1.0.7&#039;)
      ALL_ROWS
      OUTLINE_LEAF(@&quot;SEL$1&quot;)
      INDEX(@&quot;SEL$1&quot; &quot;T1&quot;@&quot;SEL$1&quot; (&quot;T1&quot;.&quot;C1&quot; &quot;T1&quot;.&quot;C2&quot;))
      END_OUTLINE_DATA
  */

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access(&quot;C1&quot;=4 AND &quot;C2&quot;&gt;=1 AND &quot;C2&quot;&lt;=10)
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Looks like a bug (not an enhancement) that exists in 11.1.0.6 and is already fixed in 11.1.0.7.</p>
<pre class="brush: sql; title: ; notranslate">
SQL&amp;gt; select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
CORE    11.1.0.7.0      Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production

SQL&gt; create table t1(c1 int, c2 int);

Table created.

SQL&gt; -- c1 = skewed, c2 = normal
SQL&gt; insert into t1
  2  select 1, level
  3  from dual
  4  connect by level &lt;= 10000
  5  union all
  6  select 2, level
  7  from dual
  8  connect by level &lt;= 1000
  9  union all
 10  select 3, level
 11  from dual
 12  connect by level &lt;= 100
 13  union all
 14  select 4, level
 15  from dual
 16  connect by level &lt;= 10
 17  union all
 18  select 5, level
 19  from dual
 20  connect by level  &lt;= 1;

SQL&gt; commit;

Commit complete.

SQL&gt; create index t1_n1 on t1(c1);

Index created.

SQL&gt; create index t1_n2 on t1(c2);

Index created.

SQL&gt; exec dbms_stats.gather_table_stats(user, 't1', method_opt =&gt; 'for columns c1 size skewonly');

PL/SQL procedure successfully completed.

SQL&gt; explain plan for
  2  select count(*)
  3  from t1
  4  where c1 = 4
  5  and c2 between 1 and 10;

Explained.

SQL&gt; select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
Plan hash value: 359681750

--------------------------------------------------------------------------------------
| Id  | Operation                    | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |       |     1 |     6 |     2   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE              |       |     1 |     6 |            |          |
|*  2 |   TABLE ACCESS BY INDEX ROWID| T1    |     1 |     6 |     2   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | T1_N1 |    10 |       |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------------------

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

   2 - filter(&quot;C2&quot;&gt;=1 AND &quot;C2&quot; ...

  1 SQL&gt; create or replace outline test_outln4
  2  on
  3  select count(*)
  4  from t1
  5  where c1 = 4
  6  and c2 between 1 and 10;

Outline created.

SQL&gt; alter session set use_stored_outlines = true;

Session altered.

SQL&gt; select hint from user_outline_hints
  2  where name = 'TEST_OUTLN4';

HINT
--------------------------------------------------------------------------------
INDEX_RS_ASC(@&quot;SEL$1&quot; &quot;T1&quot;@&quot;SEL$1&quot; (&quot;T1&quot;.&quot;C1&quot;))
OUTLINE_LEAF(@&quot;SEL$1&quot;)
ALL_ROWS
DB_VERSION('11.1.0.7')
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
IGNORE_OPTIM_EMBEDDED_HINTS

SQL&gt; create index t1_n3 on t1(c1, c2);

Index created.

SQL&gt; explain plan for
  2  select count(*)
  3  from t1
  4  where c1 = 4
  5  and c2 between 1 and 10;

Explained.

SQL&gt; select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
Plan hash value: 359681750

--------------------------------------------------------------------------------------
| Id  | Operation                    | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |       |     1 |     6 |     2   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE              |       |     1 |     6 |            |          |
|*  2 |   TABLE ACCESS BY INDEX ROWID| T1    |     1 |     6 |     2   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | T1_N1 |    10 |       |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------------------

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

   2 - filter(&quot;C2&quot;&gt;=1 AND &quot;C2&quot; select count(*)
  
  1 SQL&gt; select count(*)
  2  from t1
  3  where c1 = 4
  4  and c2 between 1 and 10;

  COUNT(*)
----------
        10

SQL&gt; select * from table(dbms_xplan.display_cursor(format=&gt;'+outline'));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
SQL_ID  0p19ucnnf9zpw, child number 0
-------------------------------------
select count(*) from t1 where c1 = 4 and c2 between 1 and 10

Plan hash value: 359681750

--------------------------------------------------------------------------------------
| Id  | Operation                    | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |       |       |       |     2 (100)|          |
|   1 |  SORT AGGREGATE              |       |     1 |     6 |            |          |
|*  2 |   TABLE ACCESS BY INDEX ROWID| T1    |     1 |     6 |     2   (0)| 00:00:01 |
|*  3 |    INDEX RANGE SCAN          | T1_N1 |    10 |       |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
      DB_VERSION('11.1.0.7')
      ALL_ROWS
      OUTLINE_LEAF(@&quot;SEL$1&quot;)
      INDEX_RS_ASC(@&quot;SEL$1&quot; &quot;T1&quot;@&quot;SEL$1&quot; (&quot;T1&quot;.&quot;C1&quot;))
      END_OUTLINE_DATA
  */

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

   2 - filter((&quot;C2&quot;&gt;=1 AND &quot;C2&quot; 

SQL&gt; select count(*)alter session set use_stored_outlines = false;

Session altered.

SQL&gt; select count(*)
  2  from t1
  3  where c1 = 4
  4  and c2 between 1 and 10;

  COUNT(*)
----------
        10

SQL&gt; select * from table(dbms_xplan.display_cursor(format=&gt;'+outline'));

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------
SQL_ID  0p19ucnnf9zpw, child number 1
-------------------------------------
select count(*) from t1 where c1 = 4 and c2 between 1 and 10

Plan hash value: 3096360861

---------------------------------------------------------------------------
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |       |       |       |     1 (100)|          |
|   1 |  SORT AGGREGATE   |       |     1 |     6 |            |          |
|*  2 |   INDEX RANGE SCAN| T1_N3 |     1 |     6 |     1   (0)| 00:00:01 |
---------------------------------------------------------------------------

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
      DB_VERSION('11.1.0.7')
      ALL_ROWS
      OUTLINE_LEAF(@&quot;SEL$1&quot;)
      INDEX(@&quot;SEL$1&quot; &quot;T1&quot;@&quot;SEL$1&quot; (&quot;T1&quot;.&quot;C1&quot; &quot;T1&quot;.&quot;C2&quot;))
      END_OUTLINE_DATA
  */

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

   2 - access(&quot;C1&quot;=4 AND &quot;C2&quot;&gt;=1 AND &quot;C2&quot;&amp;lt;=10)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dion Cho</title>
		<link>http://dioncho.wordpress.com/2009/07/24/stored-outline-does-not-work-the-stupidity-of-oracle-11g/#comment-355</link>
		<dc:creator><![CDATA[Dion Cho]]></dc:creator>
		<pubDate>Fri, 24 Jul 2009 22:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://dioncho.wordpress.com/?p=829#comment-355</guid>
		<description><![CDATA[@Robert. 

Could you post your case to your blog or any other place like OTN forum? 
Oracle has some restrictions on applying hints and you might be hitting one of them.]]></description>
		<content:encoded><![CDATA[<p>@Robert. </p>
<p>Could you post your case to your blog or any other place like OTN forum?<br />
Oracle has some restrictions on applying hints and you might be hitting one of them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
