<?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_Rows</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2011/03/02/first_rows/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/</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: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39999</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 15 Mar 2011 22:18:06 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39999</guid>
		<description><![CDATA[Johnwuwuwu,

Thanks for that. 

Although the title suggests the fix is for the &quot;proper&quot; first_rows_K optimisation, the description suggests that the implementation would have made it apply to the old first_rows as a side-effect (pretty much as I surmised in my &lt;a href=&quot;http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39854&quot; rel=&quot;nofollow&quot;&gt;comment above&lt;/a&gt;.]]></description>
		<content:encoded><![CDATA[<p>Johnwuwuwu,</p>
<p>Thanks for that. </p>
<p>Although the title suggests the fix is for the &#8220;proper&#8221; first_rows_K optimisation, the description suggests that the implementation would have made it apply to the old first_rows as a side-effect (pretty much as I surmised in my <a href="http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39854" rel="nofollow">comment above</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: johnwuwuwu</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39993</link>
		<dc:creator><![CDATA[johnwuwuwu]]></dc:creator>
		<pubDate>Tue, 15 Mar 2011 08:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39993</guid>
		<description><![CDATA[It seems like hit Bug 7430474(FIRST_ROWS_K recost for ORDER BY elimination may not find best plan.)]]></description>
		<content:encoded><![CDATA[<p>It seems like hit Bug 7430474(FIRST_ROWS_K recost for ORDER BY elimination may not find best plan.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dom Brooks</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39865</link>
		<dc:creator><![CDATA[Dom Brooks]]></dc:creator>
		<pubDate>Mon, 07 Mar 2011 14:18:13 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39865</guid>
		<description><![CDATA[I know we shouldn&#039;t be using first_rows anyway but...

The 11.2.0.1 behaviour reported above by hourim is inconsistent with my 11.2.0.2 at least.

Running with 11.2.0.2, optimizer_features_enable=11.2.0.2 and optimizer_mode=first_rows, my 10053 trace showed only T1_BA as considered in the recost.

Having said that, although I thought I was initially able to reproduce the 11.2.0.1 change by way of optimizer_features_enable &amp; optimizer_mode, I now think I must have been careless because subsequent attempts failed.]]></description>
		<content:encoded><![CDATA[<p>I know we shouldn&#8217;t be using first_rows anyway but&#8230;</p>
<p>The 11.2.0.1 behaviour reported above by hourim is inconsistent with my 11.2.0.2 at least.</p>
<p>Running with 11.2.0.2, optimizer_features_enable=11.2.0.2 and optimizer_mode=first_rows, my 10053 trace showed only T1_BA as considered in the recost.</p>
<p>Having said that, although I thought I was initially able to reproduce the 11.2.0.1 change by way of optimizer_features_enable &amp; optimizer_mode, I now think I must have been careless because subsequent attempts failed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39854</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sun, 06 Mar 2011 20:05:36 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39854</guid>
		<description><![CDATA[The trace file shows us that the logic has changed in 11.2. It&#039;s then an interesting philosophical question whether the code for first_rows analysis has been modified (which seems unlikely if it exists for backwards compatibility only) or whether there is a structure to the optimisation strategy that has changed - thus removing a few possible paths from consideration - and it&#039;s the arithmetic that changes within the boundaries of that structure. (I&#039;d guess the latter.)

It might be possible to construct a complete answer by doing several more experiments using a larger collection of indexes on longer lists of columns - but that&#039;s not a project I&#039;d want to pursue at present.]]></description>
		<content:encoded><![CDATA[<p>The trace file shows us that the logic has changed in 11.2. It&#8217;s then an interesting philosophical question whether the code for first_rows analysis has been modified (which seems unlikely if it exists for backwards compatibility only) or whether there is a structure to the optimisation strategy that has changed &#8211; thus removing a few possible paths from consideration &#8211; and it&#8217;s the arithmetic that changes within the boundaries of that structure. (I&#8217;d guess the latter.)</p>
<p>It might be possible to construct a complete answer by doing several more experiments using a larger collection of indexes on longer lists of columns &#8211; but that&#8217;s not a project I&#8217;d want to pursue at present.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hourim</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39848</link>
		<dc:creator><![CDATA[hourim]]></dc:creator>
		<pubDate>Sun, 06 Mar 2011 07:35:51 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39848</guid>
		<description><![CDATA[Dear Jonathan,

I generated the 10053 trace file and, if I have not missed anything, I can say that there is no recost for order by(using index) when I ordered by a,b
and there is a recost for order by(using index) when I ordered by b but this recost doesn&#039;t change the original best access path.

This is the 10053 trace file when I ordered by a, b 

[sourcecode language=&quot;sql&quot;]
optimizer_features_enable           = 11.2.0.1
optimizer_mode                      = first_rows

Access path analysis for T1
***************************************
SINGLE TABLE ACCESS PATH 
  Single Table Cardinality Estimation for T1[T1] 

  Table: T1  Alias: T1
    Card: Original: 100000.000000  Rounded: 307  Computed: 307.44  Non Adjusted: 307.44
  Access Path: TableScan
    Cost:  506.27  Resp: 506.27  Degree: 0
      Cost_io: 503.00  Cost_cpu: 35196627
      Resp_io: 503.00  Resp_cpu: 35196627
kkofmx: index filter:&quot;T1&quot;.&quot;A&quot;=&#039;20110401&#039;

  Access Path: index (skip-scan)
    SS sel: 0.003074  ANDV (#skips): 308.000000
    SS io: 308.000000 vs. index scan io: 503.000000
    Skip Scan chosen
  Access Path: index (SkipScan)
    Index: T1_BA
    resc_io: 617.00  resc_cpu: 23882848
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 619.22  Resp: 619.22  Degree: 1

  Access Path: index (RangeScan)
    Index: T1_PK
    resc_io: 10.00  resc_cpu: 191334
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 10.02  Resp: 10.02  Degree: 1
  ****** trying bitmap/domain indexes ******
  ****** finished trying bitmap/domain indexes ******
  Best:: AccessPath: IndexRange
  Index: T1_PK
         Cost: 10.02  Degree: 1  Resp: 10.02  Card: 307.44  Bytes: 0
***************************************

[/sourcecode]

And this is the 10053 trace file when I ordered by b only

[sourcecode language=&quot;sql&quot;]

optimizer_features_enable           = 11.2.0.1
optimizer_mode                      = first_rows

Access path analysis for T1
***************************************
SINGLE TABLE ACCESS PATH 
  Single Table Cardinality Estimation for T1[T1] 

  Table: T1  Alias: T1
    Card: Original: 100000.000000  Rounded: 307  Computed: 307.44  Non Adjusted: 307.44
  Access Path: TableScan
    Cost:  506.27  Resp: 506.27  Degree: 0
      Cost_io: 503.00  Cost_cpu: 35196627
      Resp_io: 503.00  Resp_cpu: 35196627
kkofmx: index filter:&quot;T1&quot;.&quot;A&quot;=&#039;20110401&#039;

  Access Path: index (skip-scan)
    SS sel: 0.003074  ANDV (#skips): 308.000000
    SS io: 308.000000 vs. index scan io: 503.000000
    Skip Scan chosen
  Access Path: index (SkipScan)
    Index: T1_BA
    resc_io: 617.00  resc_cpu: 23882848
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 619.22  Resp: 619.22  Degree: 1

  Access Path: index (RangeScan)
    Index: T1_PK
    resc_io: 10.00  resc_cpu: 191334
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 10.02  Resp: 10.02  Degree: 1
  ****** trying bitmap/domain indexes ******
  ****** finished trying bitmap/domain indexes ******
  Best:: AccessPath: IndexRange
  Index: T1_PK
         Cost: 10.02  Degree: 1  Resp: 10.02  Card: 307.44  Bytes: 0


****** Recost for ORDER BY (using index) ************
Access path analysis for T1
***************************************
SINGLE TABLE ACCESS PATH 
  Single Table Cardinality Estimation for T1[T1] 

  Table: T1  Alias: T1
    Card: Original: 100000.000000  Rounded: 307  Computed: 307.44  Non Adjusted: 307.44
  Access Path: TableScan
    Cost:  506.27  Resp: 506.27  Degree: 0
      Cost_io: 503.00  Cost_cpu: 35196627
      Resp_io: 503.00  Resp_cpu: 35196627

  Access Path: index (RangeScan)
    Index: T1_PK
    resc_io: 10.00  resc_cpu: 191334
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 10.02  Resp: 10.02  Degree: 1
  Best:: AccessPath: IndexRange
  Index: T1_PK
         Cost: 10.02  Degree: 1  Resp: 10.02  Card: 307.44  Bytes: 24

[/sourcecode]

Best Regards]]></description>
		<content:encoded><![CDATA[<p>Dear Jonathan,</p>
<p>I generated the 10053 trace file and, if I have not missed anything, I can say that there is no recost for order by(using index) when I ordered by a,b<br />
and there is a recost for order by(using index) when I ordered by b but this recost doesn&#8217;t change the original best access path.</p>
<p>This is the 10053 trace file when I ordered by a, b </p>
<pre class="brush: sql; title: ; notranslate">
optimizer_features_enable           = 11.2.0.1
optimizer_mode                      = first_rows

Access path analysis for T1
***************************************
SINGLE TABLE ACCESS PATH 
  Single Table Cardinality Estimation for T1[T1] 

  Table: T1  Alias: T1
    Card: Original: 100000.000000  Rounded: 307  Computed: 307.44  Non Adjusted: 307.44
  Access Path: TableScan
    Cost:  506.27  Resp: 506.27  Degree: 0
      Cost_io: 503.00  Cost_cpu: 35196627
      Resp_io: 503.00  Resp_cpu: 35196627
kkofmx: index filter:&quot;T1&quot;.&quot;A&quot;='20110401'

  Access Path: index (skip-scan)
    SS sel: 0.003074  ANDV (#skips): 308.000000
    SS io: 308.000000 vs. index scan io: 503.000000
    Skip Scan chosen
  Access Path: index (SkipScan)
    Index: T1_BA
    resc_io: 617.00  resc_cpu: 23882848
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 619.22  Resp: 619.22  Degree: 1

  Access Path: index (RangeScan)
    Index: T1_PK
    resc_io: 10.00  resc_cpu: 191334
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 10.02  Resp: 10.02  Degree: 1
  ****** trying bitmap/domain indexes ******
  ****** finished trying bitmap/domain indexes ******
  Best:: AccessPath: IndexRange
  Index: T1_PK
         Cost: 10.02  Degree: 1  Resp: 10.02  Card: 307.44  Bytes: 0
***************************************

</pre>
<p>And this is the 10053 trace file when I ordered by b only</p>
<pre class="brush: sql; title: ; notranslate">

optimizer_features_enable           = 11.2.0.1
optimizer_mode                      = first_rows

Access path analysis for T1
***************************************
SINGLE TABLE ACCESS PATH 
  Single Table Cardinality Estimation for T1[T1] 

  Table: T1  Alias: T1
    Card: Original: 100000.000000  Rounded: 307  Computed: 307.44  Non Adjusted: 307.44
  Access Path: TableScan
    Cost:  506.27  Resp: 506.27  Degree: 0
      Cost_io: 503.00  Cost_cpu: 35196627
      Resp_io: 503.00  Resp_cpu: 35196627
kkofmx: index filter:&quot;T1&quot;.&quot;A&quot;='20110401'

  Access Path: index (skip-scan)
    SS sel: 0.003074  ANDV (#skips): 308.000000
    SS io: 308.000000 vs. index scan io: 503.000000
    Skip Scan chosen
  Access Path: index (SkipScan)
    Index: T1_BA
    resc_io: 617.00  resc_cpu: 23882848
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 619.22  Resp: 619.22  Degree: 1

  Access Path: index (RangeScan)
    Index: T1_PK
    resc_io: 10.00  resc_cpu: 191334
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 10.02  Resp: 10.02  Degree: 1
  ****** trying bitmap/domain indexes ******
  ****** finished trying bitmap/domain indexes ******
  Best:: AccessPath: IndexRange
  Index: T1_PK
         Cost: 10.02  Degree: 1  Resp: 10.02  Card: 307.44  Bytes: 0


****** Recost for ORDER BY (using index) ************
Access path analysis for T1
***************************************
SINGLE TABLE ACCESS PATH 
  Single Table Cardinality Estimation for T1[T1] 

  Table: T1  Alias: T1
    Card: Original: 100000.000000  Rounded: 307  Computed: 307.44  Non Adjusted: 307.44
  Access Path: TableScan
    Cost:  506.27  Resp: 506.27  Degree: 0
      Cost_io: 503.00  Cost_cpu: 35196627
      Resp_io: 503.00  Resp_cpu: 35196627

  Access Path: index (RangeScan)
    Index: T1_PK
    resc_io: 10.00  resc_cpu: 191334
    ix_sel: 0.003074  ix_sel_with_filters: 0.003074 
    Cost: 10.02  Resp: 10.02  Degree: 1
  Best:: AccessPath: IndexRange
  Index: T1_PK
         Cost: 10.02  Degree: 1  Resp: 10.02  Card: 307.44  Bytes: 24

</pre>
<p>Best Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39835</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 05 Mar 2011 08:57:24 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39835</guid>
		<description><![CDATA[Since you&#039;re running 11.2.0.1 the first guess would be that Oracle has recognised a bug in earlier versions and fixed it - have you checked the release notes to see if there is anything about &quot;bad choice of index under first_rows&quot; ?

Although optimizer_features_enable will make the optimizer revert to earlier behaviour, I don&#039;t think there&#039;s any guarantee that it will re-introduce bugs that were present in earlier versions.

In your case I&#039;d look at the 10053 trace to see if my comment about the &quot;recost&quot; is still true:

&lt;ul&gt;&lt;em&gt;
The most significant difference was the choice of indexes examined when the optimizer was doing the “recost for order by” bit. When we ordered by a,b the optimizer considered only the t1_ba index 
&lt;/em&gt;&lt;/ul&gt;]]></description>
		<content:encoded><![CDATA[<p>Since you&#8217;re running 11.2.0.1 the first guess would be that Oracle has recognised a bug in earlier versions and fixed it &#8211; have you checked the release notes to see if there is anything about &#8220;bad choice of index under first_rows&#8221; ?</p>
<p>Although optimizer_features_enable will make the optimizer revert to earlier behaviour, I don&#8217;t think there&#8217;s any guarantee that it will re-introduce bugs that were present in earlier versions.</p>
<p>In your case I&#8217;d look at the 10053 trace to see if my comment about the &#8220;recost&#8221; is still true:</p>
<ul><em><br />
The most significant difference was the choice of indexes examined when the optimizer was doing the “recost for order by” bit. When we ordered by a,b the optimizer considered only the t1_ba index<br />
</em></ul>
]]></content:encoded>
	</item>
	<item>
		<title>By: hourim</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39834</link>
		<dc:creator><![CDATA[hourim]]></dc:creator>
		<pubDate>Sat, 05 Mar 2011 08:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39834</guid>
		<description><![CDATA[Sorry Jonathan,

Is it possible to let me know why I have the following observations?

Thanks in advance
[sourcecode gutter=&quot;false&quot;]
SQL&gt; select * from v$version
  2  where rownum=1;

BANNER                                                                                                      
-----------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                        

SQL&gt; alter session set optimizer_features_enable=&#039;10.2.0.3&#039;;

Session modifiée.

SQL&gt; select index_name, table_name
  2  from user_indexes
  3  where table_name=&#039;T1&#039;;

INDEX_NAME       TABLE_NAME                                                                     
------------------------------                                                  
T1_PK              T1                                                                             
T1_BA              T1                                                                             

SQL&gt; alter session set optimizer_mode = first_rows;

Session modifiée.

SQL&gt; select
  2      small_vc
  3  from
  4      t1
  5  where
  6      a = &#039;20110401&#039;
  7  and b &gt; 10
  8  order by
  9      a, b
 10  ;
                                                                                     

307 ligne(s) sélectionnée(s).

SQL&gt; select * from table(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT                                                                                           
---------------------------------------------------------------------------------------------
SQL_ID bdfa9jku43jfh,child number 2                                                                         
-------------------------------------                                                                       
select     small_vc from     t1 where     a = &#039;20110401&#039; and b &gt; 10                                           
order by     a,b                                                                                             
                                                                                                            
Plan hash value: 3756972603                                                                                                                                                                                        
--------------------------------------------------------------------------------------                      
&#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;    11 (100)&#124;          &#124;                     
&#124;   1 &#124;  SORT ORDER BY               &#124;       &#124;   307 &#124;  7368 &#124;    11  (10)&#124; 00:00:01 &#124;                      
&#124;   2 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;   307 &#124;  7368 &#124;    10   (0)&#124; 00:00:01 &#124;                      
&#124;*  3 &#124;    INDEX RANGE SCAN          &#124; T1_PK &#124;   307 &#124;       &#124;     2   (0)&#124; 00:00:01 &#124;                      
--------------------------------------------------------------------------------------                                                                                                                               
Predicate Information(identified by operationid):                                                           
---------------------------------------------------                                                                                                                                              
 3 - access(&quot;A&quot;=&#039;20110401&#039; AND &quot;B&quot;&gt;10)                                                                      
                                                                                                            
SQL&gt; select
  2      /*+ index(t1(a,b)) */
  3      small_vc
  4  from
  5      t1
  6  where
  7      a = &#039;20110401&#039;
  8  and b &gt; 10
  9  order by
 10      a, b
 11  ;
                                                                           
307 ligne(s) sélectionnée(s).

SQL&gt; select * from table(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT                                                                                           
-----------------------------------------------------------------------------------
SQL_ID  20ppz5r9gk99q, child number 2                                                                       
-------------------------------------                                                                       
select     /*+ index(t1(a,b)) */     small_vc from     t1 where     
a =&#039;20110401&#039; and b &gt; 10 order by  a,b                                                                                                                                                                                  
Plan hash value: 3756972603                                                                                                                                                                                         
--------------------------------------------------------------------------------------                      
&#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;    11 (100)&#124;        &#124;                                                                                            
&#124;   1 &#124;  SORT ORDER BY               &#124;       &#124;   307 &#124;  7368 &#124;    11  (10)&#124; 00:00:01 &#124;                      
&#124;   2 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;   307 &#124;  7368 &#124;    10   (0)&#124; 00:00:01 &#124;                      
&#124;*  3 &#124;    INDEX RANGE SCAN          &#124; T1_PK &#124;   307 &#124;       &#124;     2   (0)&#124; 00:00:01 &#124;                      
--------------------------------------------------------------------------------------                      
                                                                                                 
Predicate Information(identified by operationid):                                                           
---------------------------------------------------                                                                                                                                                 
 3 - access(&quot;A&quot;=&#039;20110401&#039; AND &quot;B&quot;&gt;10)
[/sourcecode]
]]></description>
		<content:encoded><![CDATA[<p>Sorry Jonathan,</p>
<p>Is it possible to let me know why I have the following observations?</p>
<p>Thanks in advance</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
SQL&gt; select * from v$version
  2  where rownum=1;

BANNER                                                                                                      
-----------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production                                        

SQL&gt; alter session set optimizer_features_enable='10.2.0.3';

Session modifiée.

SQL&gt; select index_name, table_name
  2  from user_indexes
  3  where table_name='T1';

INDEX_NAME       TABLE_NAME                                                                     
------------------------------                                                  
T1_PK              T1                                                                             
T1_BA              T1                                                                             

SQL&gt; alter session set optimizer_mode = first_rows;

Session modifiée.

SQL&gt; select
  2      small_vc
  3  from
  4      t1
  5  where
  6      a = '20110401'
  7  and b &gt; 10
  8  order by
  9      a, b
 10  ;
                                                                                     

307 ligne(s) sélectionnée(s).

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

PLAN_TABLE_OUTPUT                                                                                           
---------------------------------------------------------------------------------------------
SQL_ID bdfa9jku43jfh,child number 2                                                                         
-------------------------------------                                                                       
select     small_vc from     t1 where     a = '20110401' and b &gt; 10                                           
order by     a,b                                                                                             
                                                                                                            
Plan hash value: 3756972603                                                                                                                                                                                        
--------------------------------------------------------------------------------------                      
| Id  | Operation                    | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                      
--------------------------------------------------------------------------------------                      
|   0 | SELECT STATEMENT             |       |       |       |    11 (100)|          |                     
|   1 |  SORT ORDER BY               |       |   307 |  7368 |    11  (10)| 00:00:01 |                      
|   2 |   TABLE ACCESS BY INDEX ROWID| T1    |   307 |  7368 |    10   (0)| 00:00:01 |                      
|*  3 |    INDEX RANGE SCAN          | T1_PK |   307 |       |     2   (0)| 00:00:01 |                      
--------------------------------------------------------------------------------------                                                                                                                               
Predicate Information(identified by operationid):                                                           
---------------------------------------------------                                                                                                                                              
 3 - access(&quot;A&quot;='20110401' AND &quot;B&quot;&gt;10)                                                                      
                                                                                                            
SQL&gt; select
  2      /*+ index(t1(a,b)) */
  3      small_vc
  4  from
  5      t1
  6  where
  7      a = '20110401'
  8  and b &gt; 10
  9  order by
 10      a, b
 11  ;
                                                                           
307 ligne(s) sélectionnée(s).

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

PLAN_TABLE_OUTPUT                                                                                           
-----------------------------------------------------------------------------------
SQL_ID  20ppz5r9gk99q, child number 2                                                                       
-------------------------------------                                                                       
select     /*+ index(t1(a,b)) */     small_vc from     t1 where     
a ='20110401' and b &gt; 10 order by  a,b                                                                                                                                                                                  
Plan hash value: 3756972603                                                                                                                                                                                         
--------------------------------------------------------------------------------------                      
| Id  | Operation                    | Name  | Rows  | Bytes | Cost (%CPU)| Time     |                      
--------------------------------------------------------------------------------------                      
|   0 | SELECT STATEMENT             |       |       |       |    11 (100)|        |                                                                                            
|   1 |  SORT ORDER BY               |       |   307 |  7368 |    11  (10)| 00:00:01 |                      
|   2 |   TABLE ACCESS BY INDEX ROWID| T1    |   307 |  7368 |    10   (0)| 00:00:01 |                      
|*  3 |    INDEX RANGE SCAN          | T1_PK |   307 |       |     2   (0)| 00:00:01 |                      
--------------------------------------------------------------------------------------                      
                                                                                                 
Predicate Information(identified by operationid):                                                           
---------------------------------------------------                                                                                                                                                 
 3 - access(&quot;A&quot;='20110401' AND &quot;B&quot;&gt;10)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39821</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 03 Mar 2011 17:53:01 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39821</guid>
		<description><![CDATA[Dom.
I&#039;d forgotten all about that thread. It&#039;s a pity that it died after I made the suggestion to rename the index. It would have been nice to have confirmation that it (probably) didn&#039;t have an effect.

Looking at it again, I do wonder if the first_rows algorithm recosts all index-driven paths that bypass the &quot;order by&quot; -  but, in this (these) cases, &quot;knows&quot; that the current best path is index-driven and therefore doesn&#039;t include it in the recosting, then forgets to cross-check its cost against the ones it has recosted.  It would be a fairly simple logic (or even counting) error to make this mistake.]]></description>
		<content:encoded><![CDATA[<p>Dom.<br />
I&#8217;d forgotten all about that thread. It&#8217;s a pity that it died after I made the suggestion to rename the index. It would have been nice to have confirmation that it (probably) didn&#8217;t have an effect.</p>
<p>Looking at it again, I do wonder if the first_rows algorithm recosts all index-driven paths that bypass the &#8220;order by&#8221; &#8211;  but, in this (these) cases, &#8220;knows&#8221; that the current best path is index-driven and therefore doesn&#8217;t include it in the recosting, then forgets to cross-check its cost against the ones it has recosted.  It would be a fairly simple logic (or even counting) error to make this mistake.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dom Brooks</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39819</link>
		<dc:creator><![CDATA[Dom Brooks]]></dc:creator>
		<pubDate>Thu, 03 Mar 2011 12:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39819</guid>
		<description><![CDATA[&gt; The first thought you might have when looking at this example is the first_rows has a heuristic
Indeed. I did.

On a similar case on OTN a while back, http://forums.oracle.com/forums/message.jspa?messageID=3231089#3231089 ,there was also a suggestion that the naming of the index might make a difference - i.e. first in alphabetical order. I did a quick test similar to above and it didn&#039;t seem to.]]></description>
		<content:encoded><![CDATA[<p>&gt; The first thought you might have when looking at this example is the first_rows has a heuristic<br />
Indeed. I did.</p>
<p>On a similar case on OTN a while back, <a href="http://forums.oracle.com/forums/message.jspa?messageID=3231089#3231089" rel="nofollow">http://forums.oracle.com/forums/message.jspa?messageID=3231089#3231089</a> ,there was also a suggestion that the naming of the index might make a difference &#8211; i.e. first in alphabetical order. I did a quick test similar to above and it didn&#8217;t seem to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://jonathanlewis.wordpress.com/2011/03/02/first_rows/#comment-39814</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Thu, 03 Mar 2011 09:48:21 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5868#comment-39814</guid>
		<description><![CDATA[&lt;blockquote&gt;Oracle doesn’t create a new index (a,b) because it can protect the primary key with the existing non-unique index (b,a).&lt;/blockquote&gt;
Yep, this is it. I completely forgot about such thing.]]></description>
		<content:encoded><![CDATA[<blockquote><p>Oracle doesn’t create a new index (a,b) because it can protect the primary key with the existing non-unique index (b,a).</p></blockquote>
<p>Yep, this is it. I completely forgot about such thing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
