<?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: Cursor Sharing 3</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Mon, 20 May 2013 01:44:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Bertran Saragusti</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-40326</link>
		<dc:creator><![CDATA[Bertran Saragusti]]></dc:creator>
		<pubDate>Wed, 13 Apr 2011 15:48:27 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-40326</guid>
		<description><![CDATA[Hi Jonathan,

  Sorry I didn&#039;t put another comment earlier but I didn&#039;t get your post via email ( I think I checked the box !!! weird ).

  Anyway... our database is 10.2.0.4 and I finally solved the issue adding a hint with the name of the index :

SELECT ...
FROM ...
WHERE ...
  and ... IN (SELECT /*+ index(pp FBI)*/...
              FROM ... PP 
              WHERE ... );

  That approach is much better than the hint &quot;cursor_sharing_exact&quot; for our needs.

Bertran.]]></description>
		<content:encoded><![CDATA[<p>Hi Jonathan,</p>
<p>  Sorry I didn&#8217;t put another comment earlier but I didn&#8217;t get your post via email ( I think I checked the box !!! weird ).</p>
<p>  Anyway&#8230; our database is 10.2.0.4 and I finally solved the issue adding a hint with the name of the index :</p>
<p>SELECT &#8230;<br />
FROM &#8230;<br />
WHERE &#8230;<br />
  and &#8230; IN (SELECT /*+ index(pp FBI)*/&#8230;<br />
              FROM &#8230; PP<br />
              WHERE &#8230; );</p>
<p>  That approach is much better than the hint &#8220;cursor_sharing_exact&#8221; for our needs.</p>
<p>Bertran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-40145</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Sat, 26 Mar 2011 12:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-40145</guid>
		<description><![CDATA[Bertran
I am surprised that this works at all when &lt;strong&gt;cursor_sharing&lt;/strong&gt; is set to anything other  than exact.

The fact that the index doesn&#039;t work in the subquery example may be nothing to do with the setting for cursor_sharing, and may depend on other transformations taking place.  In the absence of any information about the version of Oracle, the actual execution plan, and the actual use of predicates, it&#039;s impossible to come to any conclusion.]]></description>
		<content:encoded><![CDATA[<p>Bertran<br />
I am surprised that this works at all when <strong>cursor_sharing</strong> is set to anything other  than exact.</p>
<p>The fact that the index doesn&#8217;t work in the subquery example may be nothing to do with the setting for cursor_sharing, and may depend on other transformations taking place.  In the absence of any information about the version of Oracle, the actual execution plan, and the actual use of predicates, it&#8217;s impossible to come to any conclusion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bertran Saragusti</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-40088</link>
		<dc:creator><![CDATA[Bertran Saragusti]]></dc:creator>
		<pubDate>Mon, 21 Mar 2011 18:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-40088</guid>
		<description><![CDATA[Hi Jonathan,

  I think I have a similar issue. I created a FBI which is used when queried &quot;directly&quot; but not when used in an IN clause. Maybe this is due to the optimizer not taking into account that index for some reason.

  Example :

Select ...
From some_table
Where translate(some_column,&#039;0123...abc...ABC...&#039;,&#039;0123&#039;)=&#039;123&#039;;

  That case works even using cs similar, but this other doesn&#039;t :

Select ...
From some_join
Where filter column in ( select_from_prior_example );

  This case doesn&#039;t take FBI into account unless I add the hint :

Select /*+ cursor_sharing_exact */...
From some_join
Where filter column in ( select_from_prior_example );

  I have tried your view approach bu didn&#039;t work.

  Can you shed some light on this ?

Thanks,
Bertran.]]></description>
		<content:encoded><![CDATA[<p>Hi Jonathan,</p>
<p>  I think I have a similar issue. I created a FBI which is used when queried &#8220;directly&#8221; but not when used in an IN clause. Maybe this is due to the optimizer not taking into account that index for some reason.</p>
<p>  Example :</p>
<p>Select &#8230;<br />
From some_table<br />
Where translate(some_column,&#8217;0123&#8230;abc&#8230;ABC&#8230;&#8217;,&#8217;0123&#8242;)=&#8217;123&#8242;;</p>
<p>  That case works even using cs similar, but this other doesn&#8217;t :</p>
<p>Select &#8230;<br />
From some_join<br />
Where filter column in ( select_from_prior_example );</p>
<p>  This case doesn&#8217;t take FBI into account unless I add the hint :</p>
<p>Select /*+ cursor_sharing_exact */&#8230;<br />
From some_join<br />
Where filter column in ( select_from_prior_example );</p>
<p>  I have tried your view approach bu didn&#8217;t work.</p>
<p>  Can you shed some light on this ?</p>
<p>Thanks,<br />
Bertran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #188, a Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-36193</link>
		<dc:creator><![CDATA[Log Buffer #188, a Carnival of the Vanities for DBAs &#124; The Pythian Blog]]></dc:creator>
		<pubDate>Mon, 10 May 2010 15:00:18 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-36193</guid>
		<description><![CDATA[[...] also shares an interesting case where a function based index is not used, even though it should [...]]]></description>
		<content:encoded><![CDATA[<p>[...] also shares an interesting case where a function based index is not used, even though it should [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-36154</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 04 May 2010 23:03:11 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-36154</guid>
		<description><![CDATA[Asif,

Sometimes you get a good idea by going back and looking again at something you&#039;ve done in the past and asking yourself if there&#039;s a (possibly new) alternative. Your comment here, for example, prompted me to think of the &quot;obvious&quot; new solution - if you&#039;re running 11g you just declare a virtual column to match the substr() requirement and create an index on the virtual column (remembering to collect stats on the virtual column, of course) then modify the code accordingly.]]></description>
		<content:encoded><![CDATA[<p>Asif,</p>
<p>Sometimes you get a good idea by going back and looking again at something you&#8217;ve done in the past and asking yourself if there&#8217;s a (possibly new) alternative. Your comment here, for example, prompted me to think of the &#8220;obvious&#8221; new solution &#8211; if you&#8217;re running 11g you just declare a virtual column to match the substr() requirement and create an index on the virtual column (remembering to collect stats on the virtual column, of course) then modify the code accordingly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asif Momen</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-36151</link>
		<dc:creator><![CDATA[Asif Momen]]></dc:creator>
		<pubDate>Tue, 04 May 2010 07:22:33 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-36151</guid>
		<description><![CDATA[I have witnessed this behavior but never thought of encapsulating function-based expression inside a view.]]></description>
		<content:encoded><![CDATA[<p>I have witnessed this behavior but never thought of encapsulating function-based expression inside a view.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jimmy</title>
		<link>http://jonathanlewis.wordpress.com/2010/05/03/cursor-sharing-3/#comment-36145</link>
		<dc:creator><![CDATA[Jimmy]]></dc:creator>
		<pubDate>Mon, 03 May 2010 21:53:31 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=3572#comment-36145</guid>
		<description><![CDATA[I took a slightly different approach on Oracle 10.2.0.4 and left cursor_sharing set to its default value EXACT.

After I created the index I queried the user_tab_cols view.

jbrock@orcl10g-local&gt; select column_name, num_distinct, hidden_column,virtual_column
  2  from user_tab_cols where table_name = &#039;T1&#039;;

COLUMN_NAME                    NUM_DISTINCT HID VIR
------------------------------ ------------ --- ---
ID                                          NO  NO
VC1                                         NO  NO
PADDING                                     NO  NO
SYS_NC00004$                                YES YES

Appears Oracle creates a hidden/virtual column for FBIs.
NUM_DISTINCT is null because I haven&#039;t gathered stats.

jbrock@orcl10g-local&gt; begin
  2  	dbms_stats.gather_table_stats(
  3  		ownname		 =&gt; user,
  4  		tabname		 =&gt;&#039;T1&#039;,
  5  		estimate_percent =&gt; 100,
  6  		method_opt 	 =&gt; &#039;for all hidden columns size 1&#039;
  7  	);
  8  end;
  9  /

For FBIs I usually used the &#039;hidden columns&#039; trick I learned from Richard Foote&#039;s seminar.

Now I rerun the user_tab_cols query again.

jbrock@orcl10g-local&gt; select column_name, num_distinct, hidden_column,virtual_column
  2   from user_tab_cols where table_name = &#039;T1&#039;;

COLUMN_NAME                    NUM_DISTINCT HID VIR
------------------------------ ------------ --- ---
ID                                          NO  NO
VC1                                         NO  NO
PADDING                                     NO  NO
SYS_NC00004$                            676 YES YES

Now that it can see some values I continue with the script you posted and got the following execution plan.

alter session set statistics_level=&#039;all&#039;;
select * from table(dbms_xplan.display_cursor);

---------------------------------------------------------------------------------------   
&#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;    16 (100)&#124;          &#124;                                  
&#124;   1 &#124;  TABLE ACCESS BY INDEX ROWID&#124; T1      &#124;    15 &#124;  1710 &#124;    16   (0)&#124; 00:00:01 &#124;                                  
&#124;*  2 &#124;   INDEX RANGE SCAN          &#124; T1_FBI1 &#124;    15 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;                                   
---------------------------------------------------------------------------------------                           
Predicate Information (identified by operation id):                                                                          
---------------------------------------------------                               
   2 - access(&quot;T1&quot;.&quot;SYS_NC00004$&quot;=&#039;zz&#039;)]]></description>
		<content:encoded><![CDATA[<p>I took a slightly different approach on Oracle 10.2.0.4 and left cursor_sharing set to its default value EXACT.</p>
<p>After I created the index I queried the user_tab_cols view.</p>
<p>jbrock@orcl10g-local&gt; select column_name, num_distinct, hidden_column,virtual_column<br />
  2  from user_tab_cols where table_name = &#8216;T1&#8242;;</p>
<p>COLUMN_NAME                    NUM_DISTINCT HID VIR<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212; &#8212; &#8212;<br />
ID                                          NO  NO<br />
VC1                                         NO  NO<br />
PADDING                                     NO  NO<br />
SYS_NC00004$                                YES YES</p>
<p>Appears Oracle creates a hidden/virtual column for FBIs.<br />
NUM_DISTINCT is null because I haven&#8217;t gathered stats.</p>
<p>jbrock@orcl10g-local&gt; begin<br />
  2  	dbms_stats.gather_table_stats(<br />
  3  		ownname		 =&gt; user,<br />
  4  		tabname		 =&gt;&#8217;T1&#8242;,<br />
  5  		estimate_percent =&gt; 100,<br />
  6  		method_opt 	 =&gt; &#8216;for all hidden columns size 1&#8242;<br />
  7  	);<br />
  8  end;<br />
  9  /</p>
<p>For FBIs I usually used the &#8216;hidden columns&#8217; trick I learned from Richard Foote&#8217;s seminar.</p>
<p>Now I rerun the user_tab_cols query again.</p>
<p>jbrock@orcl10g-local&gt; select column_name, num_distinct, hidden_column,virtual_column<br />
  2   from user_tab_cols where table_name = &#8216;T1&#8242;;</p>
<p>COLUMN_NAME                    NUM_DISTINCT HID VIR<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212; &#8212; &#8212;<br />
ID                                          NO  NO<br />
VC1                                         NO  NO<br />
PADDING                                     NO  NO<br />
SYS_NC00004$                            676 YES YES</p>
<p>Now that it can see some values I continue with the script you posted and got the following execution plan.</p>
<p>alter session set statistics_level=&#8217;all&#8217;;<br />
select * from table(dbms_xplan.display_cursor);</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
| Id  | Operation                   | Name    | Rows  | Bytes | Cost (%CPU)| Time     |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
|   0 | SELECT STATEMENT            |         |       |       |    16 (100)|          |<br />
|   1 |  TABLE ACCESS BY INDEX ROWID| T1      |    15 |  1710 |    16   (0)| 00:00:01 |<br />
|*  2 |   INDEX RANGE SCAN          | T1_FBI1 |    15 |       |     1   (0)| 00:00:01 |<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Predicate Information (identified by operation id):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
   2 &#8211; access(&#8220;T1&#8243;.&#8221;SYS_NC00004$&#8221;=&#8217;zz&#8217;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
