<?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"
	>
<channel>
	<title>Comments on: Bind Variable Peeking with no Histograms</title>
	<atom:link href="http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/</link>
	<description>The Alex Gorbachev Oracle Blog</description>
	<pubDate>Sun, 12 Oct 2008 19:08:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Appunti sul funzionamento di CBO in Oracle - Parte II &#171; Oracle and other</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-18282</link>
		<dc:creator>Appunti sul funzionamento di CBO in Oracle - Parte II &#171; Oracle and other</dc:creator>
		<pubDate>Tue, 15 Jul 2008 14:56:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-18282</guid>
		<description>[...] NON SONO LE CATTIVE PRESTAZIONI O LE SCELTE SBAGLIATE DI CBO. Come dice bene Alex Gorbachev in un commento al suo post intitolato &#8220;Bind peeking with no histograms&#8221; l&#8217;unico e vero problema [...]</description>
		<content:encoded><![CDATA[<p>[...] NON SONO LE CATTIVE PRESTAZIONI O LE SCELTE SBAGLIATE DI CBO. Come dice bene Alex Gorbachev in un commento al suo post intitolato &#8220;Bind peeking with no histograms&#8221; l&#8217;unico e vero problema [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Polarski Bernard</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17653</link>
		<dc:creator>Polarski Bernard</dc:creator>
		<pubDate>Fri, 30 May 2008 07:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17653</guid>
		<description>sorry I press too fast, the facts are :

peek=1 :
Access Path: TableScan
Cost:  86.84  Resp: 86.84  Degree: 0
Cost_io: 80.00  Cost_cpu: 3117218
Resp_io: 80.00  Resp_cpu: 3117218


peek=9000001

Access Path: TableScan
 Cost:  2.02  Resp: 2.02  Degree: 0
Cost_io: 2.00  Cost_cpu: 7851
Resp_io: 2.00  Resp_cpu: 7851</description>
		<content:encoded><![CDATA[<p>sorry I press too fast, the facts are :</p>
<p>peek=1 :<br />
Access Path: TableScan<br />
Cost:  86.84  Resp: 86.84  Degree: 0<br />
Cost_io: 80.00  Cost_cpu: 3117218<br />
Resp_io: 80.00  Resp_cpu: 3117218</p>
<p>peek=9000001</p>
<p>Access Path: TableScan<br />
 Cost:  2.02  Resp: 2.02  Degree: 0<br />
Cost_io: 2.00  Cost_cpu: 7851<br />
Resp_io: 2.00  Resp_cpu: 7851</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Polarski Bernard</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17652</link>
		<dc:creator>Polarski Bernard</dc:creator>
		<pubDate>Fri, 30 May 2008 07:08:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17652</guid>
		<description>Why is it that cost of full tablescan is different between the 2 peeking ?

peek=1 :

Access Path: TableScan
Cost:  86.84  Resp: 86.84  Degree: 0
Cost_io: 80.00  Cost_cpu: 3117218


peek=9000001

Cost:  86.84  Resp: 86.84  Degree: 0
Cost_io: 80.00  Cost_cpu: 3117218
Resp_io: 80.00  Resp_cpu: 3117218</description>
		<content:encoded><![CDATA[<p>Why is it that cost of full tablescan is different between the 2 peeking ?</p>
<p>peek=1 :</p>
<p>Access Path: TableScan<br />
Cost:  86.84  Resp: 86.84  Degree: 0<br />
Cost_io: 80.00  Cost_cpu: 3117218</p>
<p>peek=9000001</p>
<p>Cost:  86.84  Resp: 86.84  Degree: 0<br />
Cost_io: 80.00  Cost_cpu: 3117218<br />
Resp_io: 80.00  Resp_cpu: 3117218</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gorbachev</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17461</link>
		<dc:creator>Alex Gorbachev</dc:creator>
		<pubDate>Tue, 13 May 2008 18:24:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17461</guid>
		<description>There are cases when you want to use bind variables (majority I'd say) and when you want to use literals (rather exceptional). Unfortunately, most developers don't bother and either used binds everywhere or nowhere (there are good developers as well that do it properly - I'm luck to work with some of those).

BVP is a workaround for code where BV are used everywhere even where a literal would be more appropriate.

cursor_sharing=force/similar is workaround for the opposite - when binds are not used at all.

I think Oracle did good job disabling cursor sharing workaround by default (i.e. cursor_sharing=exact) but they did a mistake enabling BVP by default and, actually, not even exposing the underscore parameter to disable it.

Btw, when those two features are combined -- you have the more "intriguing" effects (and bugs).</description>
		<content:encoded><![CDATA[<p>There are cases when you want to use bind variables (majority I&#8217;d say) and when you want to use literals (rather exceptional). Unfortunately, most developers don&#8217;t bother and either used binds everywhere or nowhere (there are good developers as well that do it properly - I&#8217;m luck to work with some of those).</p>
<p>BVP is a workaround for code where BV are used everywhere even where a literal would be more appropriate.</p>
<p>cursor_sharing=force/similar is workaround for the opposite - when binds are not used at all.</p>
<p>I think Oracle did good job disabling cursor sharing workaround by default (i.e. cursor_sharing=exact) but they did a mistake enabling BVP by default and, actually, not even exposing the underscore parameter to disable it.</p>
<p>Btw, when those two features are combined &#8212; you have the more &#8220;intriguing&#8221; effects (and bugs).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Jones</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17448</link>
		<dc:creator>David Jones</dc:creator>
		<pubDate>Mon, 12 May 2008 10:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-17448</guid>
		<description>Thanks to all the contributors to this thread, which has been very useful in confirming and addressing our own similar problems.  

I'm intrigued by the extract of Oracle documentation posted by Jonas:

&#62;&#62;
When bind variables are used in a statement, it is assumed that cursor sharing is intended and that different invocations are supposed to use the same execution plan. If different invocations of the cursor would significantly benefit from different execution plans, then bind variables may have been used inappropriately in the SQL statement. Bind peeking works for a specific set of clients, not all clients.”
&#62;&#62;

It seems to me Oracle have painted themselves into a logical corner: In a situation where it is not the case that "different invocations of the cursor would significantly benefit from different execution plans", then there is no point in peeking the bind variable to determine the best path.  So, if the one time that peeking the variable would be useful is the scenario where "bind variables may have been used inappropriately in the SQL statement", why bother to implement bind variable peeking at all, ever?!

Did I miss something?

David</description>
		<content:encoded><![CDATA[<p>Thanks to all the contributors to this thread, which has been very useful in confirming and addressing our own similar problems.  </p>
<p>I&#8217;m intrigued by the extract of Oracle documentation posted by Jonas:</p>
<p>&gt;&gt;<br />
When bind variables are used in a statement, it is assumed that cursor sharing is intended and that different invocations are supposed to use the same execution plan. If different invocations of the cursor would significantly benefit from different execution plans, then bind variables may have been used inappropriately in the SQL statement. Bind peeking works for a specific set of clients, not all clients.”<br />
&gt;&gt;</p>
<p>It seems to me Oracle have painted themselves into a logical corner: In a situation where it is not the case that &#8220;different invocations of the cursor would significantly benefit from different execution plans&#8221;, then there is no point in peeking the bind variable to determine the best path.  So, if the one time that peeking the variable would be useful is the scenario where &#8220;bind variables may have been used inappropriately in the SQL statement&#8221;, why bother to implement bind variable peeking at all, ever?!</p>
<p>Did I miss something?</p>
<p>David</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bind Peeking, Ad Hoc Queries, Stable Performance. On 10G you can only pick any two.</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-16380</link>
		<dc:creator>Bind Peeking, Ad Hoc Queries, Stable Performance. On 10G you can only pick any two.</dc:creator>
		<pubDate>Wed, 12 Mar 2008 13:04:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-16380</guid>
		<description>[...] have been plenty of posts about bind peeking. Alex Gorbachev wrote about it last year, and so did Jonathan Lewis. It&#8217;s a well known issue. However what hasn&#8217;t been [...]</description>
		<content:encoded><![CDATA[<p>[...] have been plenty of posts about bind peeking. Alex Gorbachev wrote about it last year, and so did Jonathan Lewis. It&#8217;s a well known issue. However what hasn&#8217;t been [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gorbachev</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-16010</link>
		<dc:creator>Alex Gorbachev</dc:creator>
		<pubDate>Fri, 22 Feb 2008 03:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-16010</guid>
		<description>Thanks for the references, Milen.
In my experience _optim_peek_user_binds parameter has helped pretty much every time and especially in cases with CURSOR_SHARING=SIMILAR.
There is another interesting Metalink Note (&lt;a href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&#038;p_id=387394.1"387394.1&lt;/a rel="nofollow"&gt;) that references couple other bugs causing execution plan instability in the section "CONCLUSION" -- bugs 4567767 and 5364143.</description>
		<content:encoded><![CDATA[<p>Thanks for the references, Milen.<br />
In my experience _optim_peek_user_binds parameter has helped pretty much every time and especially in cases with CURSOR_SHARING=SIMILAR.<br />
There is another interesting Metalink Note (<a href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&#038;p_id=387394.1"387394.1</a rel="nofollow">) that references couple other bugs causing execution plan instability in the section &#8220;CONCLUSION&#8221; &#8212; bugs 4567767 and 5364143.</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Milen Kulev</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-15969</link>
		<dc:creator>Milen Kulev</dc:creator>
		<pubDate>Wed, 20 Feb 2008 14:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-15969</guid>
		<description>Hello agian Alex,
whether a bind variable is peeked depends not only the presence of histograms, bit also on the value of the parameter CURSOR_SHARING.
CBO decides to peek (provided that “_optim_peek_user_binds”=TRUE &#38; in absense of bugs -&#62; see my latest post ) the deepending on whether the bind variable is considered "unsafe". 
A very good read are ML  296377.1 and 377847.1.
According to  ML  296377.1 the "ultimate" proof (but not the reason why ! ;( ) that a bind variable is considered as "unsafe" is the oacfl2 attribute in a 10046 trace file. Short excerpt from the first ML note:

---------------------------------------------------
It is also possible to tell from 10046 trace (level 4/12 - BINDS) if a bind is considered to be unsafe

The flag oacfl2 in 9i and fl2 in 10g will show if a variable is unsafe.

BINDS #2:
bind 0: dty=2 mxl=22(04) mal=00 scl=00 pre=00 oacflg=10 oacfl2=500 size=24
offset=0
bfp=1036d6408 bln=22 avl=04 flg=09
value=16064
bind 1: dty=2 mxl=22(04) mal=00 scl=00 pre=00 oacflg=10 oacfl2=500 size=24
offset=0
bfp=1036d4340 bln=22 avl=04 flg=09

If you note oacfl2=500
#define UACFBLTR 0x00000100 /* Bind was generated by LiTeRal replacement */
#define UACFUNSL 0x00000200 /* UNSafe Literal */
#define UACFNDTL 0x00000400 /* Non-DaTa LiteRal */

---------------------------------------------------

HTH. Milen</description>
		<content:encoded><![CDATA[<p>Hello agian Alex,<br />
whether a bind variable is peeked depends not only the presence of histograms, bit also on the value of the parameter CURSOR_SHARING.<br />
CBO decides to peek (provided that “_optim_peek_user_binds”=TRUE &amp; in absense of bugs -&gt; see my latest post ) the deepending on whether the bind variable is considered &#8220;unsafe&#8221;.<br />
A very good read are ML  296377.1 and 377847.1.<br />
According to  ML  296377.1 the &#8220;ultimate&#8221; proof (but not the reason why ! ;( ) that a bind variable is considered as &#8220;unsafe&#8221; is the oacfl2 attribute in a 10046 trace file. Short excerpt from the first ML note:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
It is also possible to tell from 10046 trace (level 4/12 - BINDS) if a bind is considered to be unsafe</p>
<p>The flag oacfl2 in 9i and fl2 in 10g will show if a variable is unsafe.</p>
<p>BINDS #2:<br />
bind 0: dty=2 mxl=22(04) mal=00 scl=00 pre=00 oacflg=10 oacfl2=500 size=24<br />
offset=0<br />
bfp=1036d6408 bln=22 avl=04 flg=09<br />
value=16064<br />
bind 1: dty=2 mxl=22(04) mal=00 scl=00 pre=00 oacflg=10 oacfl2=500 size=24<br />
offset=0<br />
bfp=1036d4340 bln=22 avl=04 flg=09</p>
<p>If you note oacfl2=500<br />
#define UACFBLTR 0&#215;00000100 /* Bind was generated by LiTeRal replacement */<br />
#define UACFUNSL 0&#215;00000200 /* UNSafe Literal */<br />
#define UACFNDTL 0&#215;00000400 /* Non-DaTa LiteRal */</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>HTH. Milen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Gorbachev</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-15968</link>
		<dc:creator>Alex Gorbachev</dc:creator>
		<pubDate>Wed, 20 Feb 2008 14:37:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-15968</guid>
		<description>Thanks for this Milen. The bug itself is not public but Metalink Note &lt;a href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&#038;p_id=5082178.8" rel="nofollow"&gt;5082178.8&lt;/a&gt; says that &lt;i&gt;In &lt;b&gt;some&lt;/b&gt; situations bind peeking can occur when it should not&lt;/i&gt;.

Do you have more details about &lt;b&gt;some&lt;/b&gt; situations?</description>
		<content:encoded><![CDATA[<p>Thanks for this Milen. The bug itself is not public but Metalink Note <a href="https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&#038;p_id=5082178.8" rel="nofollow">5082178.8</a> says that <i>In <b>some</b> situations bind peeking can occur when it should not</i>.</p>
<p>Do you have more details about <b>some</b> situations?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Milen Kulev</title>
		<link>http://www.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-15966</link>
		<dc:creator>Milen Kulev</dc:creator>
		<pubDate>Wed, 20 Feb 2008 14:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.oracloid.com/2006/07/bind-variable-peeking-with-no-histograms/#comment-15966</guid>
		<description>Alex,
very useful and refreshing post.
The problem is that due to a bug 5082178 , bind variables are peekded, even if 
"_optim_peek_user_binds"=FALSE.
I have had enormous problems with plan stability  (on 10.2.0.2 ) with some SQLs,
and  "_optim_peek_user_binds" was set to FALSE.
So,  the problem should have been fixed in 10.2.0.4 , accourt to Oracle Corp.
(see  http://www.dbatools.net/doc/bug10204.html). But first I want to see and then (eventually) believe it ;) .

Best Regards. Milen</description>
		<content:encoded><![CDATA[<p>Alex,<br />
very useful and refreshing post.<br />
The problem is that due to a bug 5082178 , bind variables are peekded, even if<br />
&#8220;_optim_peek_user_binds&#8221;=FALSE.<br />
I have had enormous problems with plan stability  (on 10.2.0.2 ) with some SQLs,<br />
and  &#8220;_optim_peek_user_binds&#8221; was set to FALSE.<br />
So,  the problem should have been fixed in 10.2.0.4 , accourt to Oracle Corp.<br />
(see  <a href="http://www.dbatools.net/doc/bug10204.html" rel="nofollow">http://www.dbatools.net/doc/bug10204.html</a>). But first I want to see and then (eventually) believe it <img src='http://www.oracloid.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Best Regards. Milen</p>
]]></content:encoded>
	</item>
</channel>
</rss>
