<?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: FBI Bug</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 19 Jun 2013 18:51:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Marie Raillard</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37626</link>
		<dc:creator><![CDATA[Marie Raillard]]></dc:creator>
		<pubDate>Fri, 29 Oct 2010 11:07:39 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37626</guid>
		<description><![CDATA[Plan from initial testcase is OK awhen event 38068 is set by example at 70 or 100

alter session set events &#039;38068 trace name context forever, level 100&#039;;
So IMO this is related to Bug 4112254

Regards
Marie]]></description>
		<content:encoded><![CDATA[<p>Plan from initial testcase is OK awhen event 38068 is set by example at 70 or 100</p>
<p>alter session set events &#8217;38068 trace name context forever, level 100&#8242;;<br />
So IMO this is related to Bug 4112254</p>
<p>Regards<br />
Marie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajabaskar Thangaraj</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37306</link>
		<dc:creator><![CDATA[Rajabaskar Thangaraj]]></dc:creator>
		<pubDate>Wed, 15 Sep 2010 13:20:09 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37306</guid>
		<description><![CDATA[I tested the above scenorio in my test db. Both queries cost have same.

My test database running on 11.1.0.7 (sun solaris : 64 bit).
[sourcecode gutter=&quot;false&quot;]
Database details:
*********************

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     2048
optimizer_mode                       string      ALL_ROWS
db_file_multiblock_read_count        integer     32
compatible                           string      11.1.0


Tablespace details:
*********************


SQL&gt; select TABLESPACE_NAME,ALLOCATION_TYPE,EXTENT_MANAGEMENT,SEGMENT_SPACE_MANAGEMENT from  dba_tablespaces;

TABLESPACE_NAME                ALLOCATIO EXTENT_MAN SEGMEN
------------------------------ --------- ---------- ------
TABLE001                       USER      DICTIONARY MANUAL




SQL&gt; create table t1(  
  2      DATE1              DATE,  
  3      STRING1            VARCHAR2(40),  
  4      NUM1               NUMBER,  
  5      NUM2               NUMBER,  
  6      NUM3               NUMBER,  
  7      NUM4               NUMBER,  
  8      NUM5               NUMBER,  
  9      STRING2            VARCHAR2(3),  
 10      NUM6               NUMBER,  
 11      STRING3            VARCHAR2(240),  
 12      STRING4            VARCHAR2(240),  
 13      STRING5            VARCHAR2(240),  
 14      STRING6            VARCHAR2(240),  
 15      STRING7            VARCHAR2(240),  
 16      STRING8            VARCHAR2(240),  
 17      STRING9            VARCHAR2(10)  
 18  );  

Table created.

SQL&gt; insert into t1(  
  2      date1, num1, num3, num6, string9  
  3  )  
  4  select  
  5      sysdate + dbms_random.value(-180, +180),  
  6      trunc(dbms_random.value(0,10)),  
  7      trunc(dbms_random.value(0,10)),  
  8      trunc(dbms_random.value(0,10)),  
  9      dbms_random.string(&#039;U&#039;,6)  
 10  from dual  
 11  connect by  
 12      rownum  commit;

Commit complete.

SQL&gt; 
SQL&gt; CREATE INDEX t1_i1 ON t1 (TRUNC(DATE1), NUM3);  

Index created.

SQL&gt; 
SQL&gt; CREATE INDEX t1_i2 ON t1 (NUM3, NUM1, TRUNC(DATE1));  

Index created.



SQL&gt; begin  
  2      dbms_stats.gather_table_stats(  
  3          ownname      =&gt; &#039;TEST&#039;,  
  4          tabname      =&gt;&#039;T1&#039;,  
  5          estimate_percent =&gt; 100,  
  6          block_sample     =&gt; true,  
  7          method_opt   =&gt; &#039;for all columns size 1&#039;,  
  8          cascade      =&gt; true  
  9      );  
 10  end;  
 11  /  

PL/SQL procedure successfully completed.

SQL&gt; explain plan for  
  2  SELECT  
  3      NVL(SUM(num6),0) num6_SUM  
  4  FROM t1  
  5  WHERE  
  6      1 = 1  
  7  and num3 = :b1  
  8  AND TRUNC(date1) BETWEEN sysdate-:b2 AND sysdate-:b3  
  9  and string9 = :b4  
 10  ;  

Explained.

SQL&gt; select * from table(dbms_xplan.display)  ;  

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 683166071

---------------------------------------------------------------------------------------
&#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;    21 &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;   1 &#124;  SORT AGGREGATE               &#124;       &#124;     1 &#124;    21 &#124;            &#124;          &#124;
&#124;*  2 &#124;   FILTER                      &#124;       &#124;       &#124;       &#124;            &#124;          &#124;
&#124;*  3 &#124;    TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;     1 &#124;    21 &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;*  4 &#124;     INDEX RANGE SCAN          &#124; T1_I2 &#124;    18 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(SYSDATE@!-TO_NUMBER(:B2)=SYSDATE@!-TO_NUMBER(:B2) AND
              TRUNC(INTERNAL_FUNCTION(&quot;DATE1&quot;))=SYSDATE@!-TO_NUMBER(:B2) AND
              TRUNC(INTERNAL_FUNCTION(&quot;DATE1&quot;)) explain plan for  
  2  SELECT  
  3      /*+ index(t1 t1_i1) */  
  4      NVL(SUM(num6),0) num6_SUM  
  5  FROM t1  
  6  WHERE  
  7      1 = 1  
  8  AND num3 = :b1  
  9  AND TRUNC(date1) BETWEEN sysdate-:b2 AND sysdate-:b3  
 10  and string9 = :b4  
 11  ;  

Explained.

SQL&gt; select * from table(dbms_xplan.display)  ;

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 2267170846

---------------------------------------------------------------------------------------
&#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;    21 &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;   1 &#124;  SORT AGGREGATE               &#124;       &#124;     1 &#124;    21 &#124;            &#124;          &#124;
&#124;*  2 &#124;   FILTER                      &#124;       &#124;       &#124;       &#124;            &#124;          &#124;
&#124;*  3 &#124;    TABLE ACCESS BY INDEX ROWID&#124; T1    &#124;     1 &#124;    21 &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;*  4 &#124;     INDEX RANGE SCAN          &#124; T1_I1 &#124;    18 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(SYSDATE@!-TO_NUMBER(:B2)=SYSDATE@!-TO_NUMBER(:B2) AND
              &quot;NUM3&quot;=TO_NUMBER(:B1) AND TRUNC(INTERNAL_FUNCTION(&quot;DATE1&quot;))&lt;=SYSDATE@!-TO_NUMBE
              R(:B3))
       filter(&quot;NUM3&quot;=TO_NUMBER(:B1))

21 rows selected.
[/sourcecode]

Thanks Lewis.


Regards
Rajabaskar Thangaraj]]></description>
		<content:encoded><![CDATA[<p>I tested the above scenorio in my test db. Both queries cost have same.</p>
<p>My test database running on 11.1.0.7 (sun solaris : 64 bit).</p>
<pre class="brush: plain; gutter: false; title: ; notranslate">
Database details:
*********************

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     2048
optimizer_mode                       string      ALL_ROWS
db_file_multiblock_read_count        integer     32
compatible                           string      11.1.0


Tablespace details:
*********************


SQL&gt; select TABLESPACE_NAME,ALLOCATION_TYPE,EXTENT_MANAGEMENT,SEGMENT_SPACE_MANAGEMENT from  dba_tablespaces;

TABLESPACE_NAME                ALLOCATIO EXTENT_MAN SEGMEN
------------------------------ --------- ---------- ------
TABLE001                       USER      DICTIONARY MANUAL




SQL&gt; create table t1(  
  2      DATE1              DATE,  
  3      STRING1            VARCHAR2(40),  
  4      NUM1               NUMBER,  
  5      NUM2               NUMBER,  
  6      NUM3               NUMBER,  
  7      NUM4               NUMBER,  
  8      NUM5               NUMBER,  
  9      STRING2            VARCHAR2(3),  
 10      NUM6               NUMBER,  
 11      STRING3            VARCHAR2(240),  
 12      STRING4            VARCHAR2(240),  
 13      STRING5            VARCHAR2(240),  
 14      STRING6            VARCHAR2(240),  
 15      STRING7            VARCHAR2(240),  
 16      STRING8            VARCHAR2(240),  
 17      STRING9            VARCHAR2(10)  
 18  );  

Table created.

SQL&gt; insert into t1(  
  2      date1, num1, num3, num6, string9  
  3  )  
  4  select  
  5      sysdate + dbms_random.value(-180, +180),  
  6      trunc(dbms_random.value(0,10)),  
  7      trunc(dbms_random.value(0,10)),  
  8      trunc(dbms_random.value(0,10)),  
  9      dbms_random.string('U',6)  
 10  from dual  
 11  connect by  
 12      rownum  commit;

Commit complete.

SQL&gt; 
SQL&gt; CREATE INDEX t1_i1 ON t1 (TRUNC(DATE1), NUM3);  

Index created.

SQL&gt; 
SQL&gt; CREATE INDEX t1_i2 ON t1 (NUM3, NUM1, TRUNC(DATE1));  

Index created.



SQL&gt; begin  
  2      dbms_stats.gather_table_stats(  
  3          ownname      =&gt; 'TEST',  
  4          tabname      =&gt;'T1',  
  5          estimate_percent =&gt; 100,  
  6          block_sample     =&gt; true,  
  7          method_opt   =&gt; 'for all columns size 1',  
  8          cascade      =&gt; true  
  9      );  
 10  end;  
 11  /  

PL/SQL procedure successfully completed.

SQL&gt; explain plan for  
  2  SELECT  
  3      NVL(SUM(num6),0) num6_SUM  
  4  FROM t1  
  5  WHERE  
  6      1 = 1  
  7  and num3 = :b1  
  8  AND TRUNC(date1) BETWEEN sysdate-:b2 AND sysdate-:b3  
  9  and string9 = :b4  
 10  ;  

Explained.

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

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 683166071

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

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

   2 - filter(SYSDATE@!-TO_NUMBER(:B2)=SYSDATE@!-TO_NUMBER(:B2) AND
              TRUNC(INTERNAL_FUNCTION(&quot;DATE1&quot;))=SYSDATE@!-TO_NUMBER(:B2) AND
              TRUNC(INTERNAL_FUNCTION(&quot;DATE1&quot;)) explain plan for  
  2  SELECT  
  3      /*+ index(t1 t1_i1) */  
  4      NVL(SUM(num6),0) num6_SUM  
  5  FROM t1  
  6  WHERE  
  7      1 = 1  
  8  AND num3 = :b1  
  9  AND TRUNC(date1) BETWEEN sysdate-:b2 AND sysdate-:b3  
 10  and string9 = :b4  
 11  ;  

Explained.

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

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
Plan hash value: 2267170846

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

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

   2 - filter(SYSDATE@!-TO_NUMBER(:B2)=SYSDATE@!-TO_NUMBER(:B2) AND
              &quot;NUM3&quot;=TO_NUMBER(:B1) AND TRUNC(INTERNAL_FUNCTION(&quot;DATE1&quot;))&lt;=SYSDATE@!-TO_NUMBE
              R(:B3))
       filter(&quot;NUM3&quot;=TO_NUMBER(:B1))

21 rows selected.
</pre>
<p>Thanks Lewis.</p>
<p>Regards<br />
Rajabaskar Thangaraj</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CBO Surprise &#171; Oracle Scratchpad</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37231</link>
		<dc:creator><![CDATA[CBO Surprise &#171; Oracle Scratchpad]]></dc:creator>
		<pubDate>Tue, 07 Sep 2010 19:06:31 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37231</guid>
		<description><![CDATA[[...] cost option during its search for an execution path. It turns out that this isn&#8217;t true. In a comment attached to a note I had written about a possible bug relating to function-based indexes I was told that there are [...]]]></description>
		<content:encoded><![CDATA[<p>[...] cost option during its search for an execution path. It turns out that this isn&#8217;t true. In a comment attached to a note I had written about a possible bug relating to function-based indexes I was told that there are [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37030</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 21 Aug 2010 20:14:36 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37030</guid>
		<description><![CDATA[Aruna,

Your argument is rational, but ought to be backed up by arithmetic. 

The optimizer can make a reasonable estimate of the fraction of data that would be returned by &quot;columnX = &#039;unknown constant&#039;&quot; because it can work on the basis of &quot;number of distinct values for columnX&quot;.

For &quot;columnD between pair of unknown constants&quot; Oracle uses a guess of 0.25%.  The problem is this - when should Oracle be INCONSISTENT in its arithmetic and ignore the number it usually uses for the guess.

Let&#039;s pretend that columnX has only one known value - should Oracle take the index that starts with columnX - which means it has to scan the whole index - or should it take the index that starts with columnD because in the worst case it will have to scan the whole index but it may scan much less.

Clearly, in this extreme case, it is arguably more sensible to use the index that starts with the column using the range-based predicate. 

So - one distinct value is a special case where your rational approach should be ignored. How many distinct values should Oracle allow before it decides that it&#039;s no longer looking at a special case ?  (This is  the type of question the designers and developers  have to ask themselves when trying to create a cost-based optimiser.)
]]></description>
		<content:encoded><![CDATA[<p>Aruna,</p>
<p>Your argument is rational, but ought to be backed up by arithmetic. </p>
<p>The optimizer can make a reasonable estimate of the fraction of data that would be returned by &#8220;columnX = &#8216;unknown constant&#8217;&#8221; because it can work on the basis of &#8220;number of distinct values for columnX&#8221;.</p>
<p>For &#8220;columnD between pair of unknown constants&#8221; Oracle uses a guess of 0.25%.  The problem is this &#8211; when should Oracle be INCONSISTENT in its arithmetic and ignore the number it usually uses for the guess.</p>
<p>Let&#8217;s pretend that columnX has only one known value &#8211; should Oracle take the index that starts with columnX &#8211; which means it has to scan the whole index &#8211; or should it take the index that starts with columnD because in the worst case it will have to scan the whole index but it may scan much less.</p>
<p>Clearly, in this extreme case, it is arguably more sensible to use the index that starts with the column using the range-based predicate. </p>
<p>So &#8211; one distinct value is a special case where your rational approach should be ignored. How many distinct values should Oracle allow before it decides that it&#8217;s no longer looking at a special case ?  (This is  the type of question the designers and developers  have to ask themselves when trying to create a cost-based optimiser.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aruna Erusadla</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37029</link>
		<dc:creator><![CDATA[Aruna Erusadla]]></dc:creator>
		<pubDate>Sat, 21 Aug 2010 13:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37029</guid>
		<description><![CDATA[I assume the optimizer does not &#039;prefer&#039; to use the index created on a column which is used  for a  RANGE OF values in the predicate because it is unsure how the range would be &#039;BIG&#039; .. so if there is an index on equality condition , it will use that index 

I meant to say the index would be preferred which is created on the columns with &#039;=&#039; operators in the predicates than the the columns with the Range operator]]></description>
		<content:encoded><![CDATA[<p>I assume the optimizer does not &#8216;prefer&#8217; to use the index created on a column which is used  for a  RANGE OF values in the predicate because it is unsure how the range would be &#8216;BIG&#8217; .. so if there is an index on equality condition , it will use that index </p>
<p>I meant to say the index would be preferred which is created on the columns with &#8216;=&#8217; operators in the predicates than the the columns with the Range operator</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joel garry</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37024</link>
		<dc:creator><![CDATA[joel garry]]></dc:creator>
		<pubDate>Fri, 20 Aug 2010 21:36:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37024</guid>
		<description><![CDATA[I&#039;d like to say you&#039;re welcome :-)

Yes, it is very useful, and of course those &quot;fixed in&quot; notations are misleading, what with backports and screaming customers and all - wrong results must be taken more seriously than &quot;mere&quot; optimizer issues.

The development environment I work in has had this functionality, as part of local &quot;db-blind&quot; dictionary extensions, for many years, and it is used all over the place, very useful.  Of course, not being part of the db engine, it is easy to mess up when trying to manipulate data through sql, as in this implementation these virtual columns look like regular columns, so you update them, and that gets overwritten by the app.  I look forward with interest as to how the vendor will deal with integrating the Oracle functionality, if they do, it would certainly help if the db were aware and these things could be indexed.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;d like to say you&#8217;re welcome :-)</p>
<p>Yes, it is very useful, and of course those &#8220;fixed in&#8221; notations are misleading, what with backports and screaming customers and all &#8211; wrong results must be taken more seriously than &#8220;mere&#8221; optimizer issues.</p>
<p>The development environment I work in has had this functionality, as part of local &#8220;db-blind&#8221; dictionary extensions, for many years, and it is used all over the place, very useful.  Of course, not being part of the db engine, it is easy to mess up when trying to manipulate data through sql, as in this implementation these virtual columns look like regular columns, so you update them, and that gets overwritten by the app.  I look forward with interest as to how the vendor will deal with integrating the Oracle functionality, if they do, it would certainly help if the db were aware and these things could be indexed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Seaman</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37021</link>
		<dc:creator><![CDATA[John Seaman]]></dc:creator>
		<pubDate>Fri, 20 Aug 2010 05:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37021</guid>
		<description><![CDATA[Tom was essentailly saying that the plan given by explain plan may be incorrect where bind variables are being used if the bind variables are of a different type to the columns to which they are compared.

I wonder if you tried the same test without using bind variables if you would get the same result. From the tests Charles ran it looks as if it is the bind variables that cause the higher cost path to be chosen and that seems to be what Johnwuwuwu is saying.

I would post the links to Tom&#039;s presentation but it doesn&#039;t seem to be up yet (assuming it will be).]]></description>
		<content:encoded><![CDATA[<p>Tom was essentailly saying that the plan given by explain plan may be incorrect where bind variables are being used if the bind variables are of a different type to the columns to which they are compared.</p>
<p>I wonder if you tried the same test without using bind variables if you would get the same result. From the tests Charles ran it looks as if it is the bind variables that cause the higher cost path to be chosen and that seems to be what Johnwuwuwu is saying.</p>
<p>I would post the links to Tom&#8217;s presentation but it doesn&#8217;t seem to be up yet (assuming it will be).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37020</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 20 Aug 2010 04:35:11 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37020</guid>
		<description><![CDATA[johnwuwuwu,

Thanks for that information - even though it is rather worrying and means I will have to look at this example a lot more closely because your comment raises lots of questions:


Is this just function-based indexes, or all indexes
Is it purely heuristic, or is there some arithmetic bias as well
Does this apply to all cases of comparison with &quot;unknown&quot;  such as:

&lt;ul&gt;
	&lt;li&gt;colX between plsql_function(const1) and plsql_function(const2)
&lt;/li&gt;
	&lt;li&gt;colx between (non-correlated scalar subquery 1) and (non-correlated scalar subquery 2)&lt;/li&gt;
&lt;li&gt;colx between sys_context() and sys_context()&lt;/li&gt;
&lt;li&gt;t2.cox between t1.cola and t1.colb&lt;/li&gt;
&lt;/ul&gt;


If it is  more generic than function-based indexes, I&#039;m puzzled that I haven&#039;t noticed it before. I guess this will give me something to do on my next long-haul flight.


]]></description>
		<content:encoded><![CDATA[<p>johnwuwuwu,</p>
<p>Thanks for that information &#8211; even though it is rather worrying and means I will have to look at this example a lot more closely because your comment raises lots of questions:</p>
<p>Is this just function-based indexes, or all indexes<br />
Is it purely heuristic, or is there some arithmetic bias as well<br />
Does this apply to all cases of comparison with &#8220;unknown&#8221;  such as:</p>
<ul>
<li>colX between plsql_function(const1) and plsql_function(const2)
</li>
<li>colx between (non-correlated scalar subquery 1) and (non-correlated scalar subquery 2)</li>
<li>colx between sys_context() and sys_context()</li>
<li>t2.cox between t1.cola and t1.colb</li>
</ul>
<p>If it is  more generic than function-based indexes, I&#8217;m puzzled that I haven&#8217;t noticed it before. I guess this will give me something to do on my next long-haul flight.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: johnwuwuwu</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37012</link>
		<dc:creator><![CDATA[johnwuwuwu]]></dc:creator>
		<pubDate>Thu, 19 Aug 2010 10:03:22 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37012</guid>
		<description><![CDATA[When using bind variables we know that some costs are unreliable, we have
 to use default values. In particular, for range predicates such as those
 that match the functional index, there is a higher likelyhood of error.
 For this reason the optimizer will prefer an index that has equality
 predicates, even if the cost is higher. If bind peeking is used (this is
 not possible with explain plan) then we will be more accurate in the
 selectivity calculation and so do not have to disregard a lower cost index
 in this way.]]></description>
		<content:encoded><![CDATA[<p>When using bind variables we know that some costs are unreliable, we have<br />
 to use default values. In particular, for range predicates such as those<br />
 that match the functional index, there is a higher likelyhood of error.<br />
 For this reason the optimizer will prefer an index that has equality<br />
 predicates, even if the cost is higher. If bind peeking is used (this is<br />
 not possible with explain plan) then we will be more accurate in the<br />
 selectivity calculation and so do not have to disregard a lower cost index<br />
 in this way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/08/17/fbi-bug/#comment-37006</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 18 Aug 2010 21:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3669#comment-37006</guid>
		<description><![CDATA[John,

Thanks for the comment. I assume that Tom was reminding people that &quot;explain plan&quot; doesn&#039;t know the type of the bind variables and doesn&#039;t have any values to peek.  

In this case, though, the problem isn&#039;t so much the fact that we get the wrong plan because of those failings, it&#039;s that with (nominally) a self-consistent level of information the optimizer does the wrong thing.]]></description>
		<content:encoded><![CDATA[<p>John,</p>
<p>Thanks for the comment. I assume that Tom was reminding people that &#8220;explain plan&#8221; doesn&#8217;t know the type of the bind variables and doesn&#8217;t have any values to peek.  </p>
<p>In this case, though, the problem isn&#8217;t so much the fact that we get the wrong plan because of those failings, it&#8217;s that with (nominally) a self-consistent level of information the optimizer does the wrong thing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
