<?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/"
		>
<channel>
	<title>Comments on: Bind Variable Peeking &#8211; execution plan inefficiency</title>
	<atom:link href="http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bind-variable-peeking-execution-plan-inefficiency</link>
	<description>Oracle, Exadata, Performance, Troubleshooting - Mobile Life and Productivity.</description>
	<lastBuildDate>Wed, 08 Feb 2012 08:03:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-5601</link>
		<dc:creator>Tanel Poder</dc:creator>
		<pubDate>Fri, 29 Oct 2010 03:49:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-5601</guid>
		<description>&lt;a href=&quot;#comment-3918&quot; rel=&quot;nofollow&quot;&gt;@Boris Vayntrub&lt;/a&gt; 
No Boris,

When you removed the parameter then you just got &quot;lucky&quot; enough to get a suitable plan which worked fine for both cases. The adaptive bind peeking didn&#039;t even have to kick in. I just used this parameter for generating one of the &quot;unlucky&quot; cases reliably. Without this parameter, yes everything works in your databas X &amp; Y, but give it a few months and something *will* go wrong in database Z some day and generate such a plan...

My demo was however, entirely about the fact that IF - I repeat IF - you do get such a plan with nested loops (like I showed, for whatever reason - there are gazillions of reasons) during the first execution, then the adaptive bind peeking ain&#039;t gonna help you during 2nd exec. On third it will.</description>
		<content:encoded><![CDATA[<p><a href="#comment-3918" rel="nofollow">@Boris Vayntrub</a><br />
No Boris,</p>
<p>When you removed the parameter then you just got &#8220;lucky&#8221; enough to get a suitable plan which worked fine for both cases. The adaptive bind peeking didn&#8217;t even have to kick in. I just used this parameter for generating one of the &#8220;unlucky&#8221; cases reliably. Without this parameter, yes everything works in your databas X &#038; Y, but give it a few months and something *will* go wrong in database Z some day and generate such a plan&#8230;</p>
<p>My demo was however, entirely about the fact that IF &#8211; I repeat IF &#8211; you do get such a plan with nested loops (like I showed, for whatever reason &#8211; there are gazillions of reasons) during the first execution, then the adaptive bind peeking ain&#8217;t gonna help you during 2nd exec. On third it will.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DBA Kevlar &#187; Blog Archive &#187; Dealing with Bind Variable Peeking</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-5600</link>
		<dc:creator>DBA Kevlar &#187; Blog Archive &#187; Dealing with Bind Variable Peeking</dc:creator>
		<pubDate>Fri, 29 Oct 2010 03:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-5600</guid>
		<description>[...] Poder had a great post about bind variable peeking, http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/&#160; I run into this exact issue more often than I would like to and have found a few tricks to [...]</description>
		<content:encoded><![CDATA[<p>[...] Poder had a great post about bind variable peeking, <a href="http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/&#038;nbsp" rel="nofollow">http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/&#038;nbsp</a>; I run into this exact issue more often than I would like to and have found a few tricks to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinicius Hoffmann Bernardes</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-4263</link>
		<dc:creator>Vinicius Hoffmann Bernardes</dc:creator>
		<pubDate>Fri, 19 Mar 2010 14:43:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-4263</guid>
		<description>Hey Tanel!

I have a similar problem on a production environment at Brazil.
Do you think you can help me?

My problem is a query that changes it&#039;s behavior (execution plan) from time to time. When the time comes what happens is that we see a lot of &quot;latch: cache buffer chains&quot; and a huge CPU Spike because of the plan choosen.

All the colums of the tables involved have histograms and the table stat are not updated very often, also the sample used to collect stat from the tables are about 5%, what i think that can be too low.

I recommended to collect stat more often and with a bigger sample, but we have the problem even 2 days after the stat gathering.

What can i do next? Can you reply by e-mail?

Thank you very much.</description>
		<content:encoded><![CDATA[<p>Hey Tanel!</p>
<p>I have a similar problem on a production environment at Brazil.<br />
Do you think you can help me?</p>
<p>My problem is a query that changes it&#8217;s behavior (execution plan) from time to time. When the time comes what happens is that we see a lot of &#8220;latch: cache buffer chains&#8221; and a huge CPU Spike because of the plan choosen.</p>
<p>All the colums of the tables involved have histograms and the table stat are not updated very often, also the sample used to collect stat from the tables are about 5%, what i think that can be too low.</p>
<p>I recommended to collect stat more often and with a bigger sample, but we have the problem even 2 days after the stat gathering.</p>
<p>What can i do next? Can you reply by e-mail?</p>
<p>Thank you very much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris Vayntrub</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-3918</link>
		<dc:creator>Boris Vayntrub</dc:creator>
		<pubDate>Wed, 24 Feb 2010 15:12:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-3918</guid>
		<description>I actually spent some time  to run sql scripts to demonstrate  this issue. What I found is that the only reason optimizer does not change a plan  for second execution , when performance is bad was that &quot;ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=10;&quot; was issued earlier. If prior to executing script with &#039;SYS&#039; value of a bind variable you would change  it back : &quot;ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=100&#039; which is a default btw, optimizer would change its plan to hash join  from nested loops. So, what is an issue? Adaptive cursor does work


SQL&gt; DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

CREATE TABLE t1 AS SELECT * FROM dba_objects;
CREATE TABLE t2 AS SELECT * FROM dba_objects;
CREATE TABLE t3 AS SELECT * FROM dba_objects;

CREATE INDEX i1 ON t1(owner);
CREATE INDEX i2 ON t2(owner);
CREATE INDEX i3 ON t3(owner);

EXEC DBMS_STATS.GATHER_TABLE_STATS(user,&#039;T1&#039;,cascade=&gt;TRUE, method_opt=&gt;&#039;FOR ALL INDEXED COLUMNS SIZE 254&#039;);
EXEC DBMS_STATS.GATHER_TABLE_STATS(user,&#039;T2&#039;,cascade=&gt;TRUE, method_opt=&gt;&#039;FOR ALL INDEXED COLUMNS SIZE 254&#039;);
EXEC DBMS_STATS.GATHER_TABLE_STATS(user,&#039;T3&#039;,cascade=&gt;TRUE, method_opt=&gt;&#039;FOR ALL INDEXED COLUMNS SIZE 254&#039;);

Table dropped.

Elapsed: 00:00:00.12
SQL&gt;
Table dropped.

Elapsed: 00:00:00.14
SQL&gt;
Table dropped.

Elapsed: 00:00:00.12
SQL&gt; SQL&gt;
Table created.

Elapsed: 00:00:01.00
SQL&gt;
Table created.

Elapsed: 00:00:00.93
SQL&gt;
Table created.

Elapsed: 00:00:01.32
SQL&gt; SQL&gt;
Index created.

Elapsed: 00:00:00.56
SQL&gt;
Index created.

Elapsed: 00:00:00.60
SQL&gt;
Index created.

Elapsed: 00:00:00.54
SQL&gt; SQL&gt;
PL/SQL procedure successfully completed.

Elapsed: 00:00:00.45
SQL&gt;
PL/SQL procedure successfully completed.

Elapsed: 00:00:00.46
SQL&gt;
PL/SQL procedure successfully completed.

Elapsed: 00:00:00.46
SQL&gt;


SQL&gt; ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=10;

Session altered.

SQL&gt;
SQL&gt; VAR v VARCHAR2(100)

SQL&gt; SQL&gt; EXEC :v:=&#039;SCOTT&#039;

SET TIMING ON

PL/SQL procedure successfully completed.

SQL&gt; SQL&gt; SQL&gt;
SQL&gt; PROMPT Running query first time, this should be fast (and should use nested loops execution plan)
Running query first time, this should be fast (and should use nested loops execution plan)
SQL&gt;
SQL&gt; SELECT
  2      MIN(t1.created), MAX(t1.created)
  3  FROM
  4      t1
  5    , t2
  6    , t3
  7  WHERE
  8      t1.object_id = t2.object_id
  9  AND t2.object_id = t3.object_id
 10  AND t1.owner = :v
 11  AND t2.owner = :v
 12  AND t3.owner = :v
 13  /

SET TIMING OFF

--SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null,&#039;ALLSTATS LAST ADVANCED&#039;));
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null));

MIN(T1.CR MAX(T1.CR
--------- ---------


Elapsed: 00:00:00.01
SQL&gt; SQL&gt; SQL&gt; SQL&gt; SQL&gt;
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  5vy5qjd3fsn5c, child number 0
-------------------------------------
SELECT     MIN(t1.created), MAX(t1.created) FROM     t1   , t2   , t3
WHERE     t1.object_id = t2.object_id AND t2.object_id = t3.object_id
AND t1.owner = :v AND t2.owner = :v AND t3.owner = :v

Plan hash value: 4162198323

----------------------------------------------------------------------------------------
&#124; Id  &#124; Operation                       &#124; Name &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
----------------------------------------------------------------------------------------

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT                &#124;      &#124;       &#124;       &#124;     3 (100)&#124;          &#124;
&#124;   1 &#124;  SORT AGGREGATE                 &#124;      &#124;     1 &#124;    66 &#124;            &#124;          &#124;
&#124;   2 &#124;   NESTED LOOPS                  &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   3 &#124;    NESTED LOOPS                 &#124;      &#124;     6 &#124;   396 &#124;     3   (0)&#124; 00:00:01 &#124;
&#124;   4 &#124;     NESTED LOOPS                &#124;      &#124;     6 &#124;   282 &#124;     2   (0)&#124; 00:00:01 &#124;
&#124;   5 &#124;      TABLE ACCESS BY INDEX ROWID&#124; T1   &#124;     6 &#124;   168 &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;*  6 &#124;       INDEX RANGE SCAN          &#124; I1   &#124;     6 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;*  7 &#124;      TABLE ACCESS BY INDEX ROWID&#124; T2   &#124;     1 &#124;    19 &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;*  8 &#124;       INDEX RANGE SCAN          &#124; I2   &#124;     6 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;*  9 &#124;     INDEX RANGE SCAN            &#124; I3   &#124;     6 &#124;       &#124;     1   (0)&#124; 00:00:01 &#124;
&#124;* 10 &#124;    TABLE ACCESS BY INDEX ROWID  &#124; T3   &#124;     1 &#124;    19 &#124;     1   (0)&#124; 00:00:01 &#124;

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   6 - access(&quot;T1&quot;.&quot;OWNER&quot;=:V)
   7 - filter(&quot;T1&quot;.&quot;OBJECT_ID&quot;=&quot;T2&quot;.&quot;OBJECT_ID&quot;)
   8 - access(&quot;T2&quot;.&quot;OWNER&quot;=:V)
   9 - access(&quot;T3&quot;.&quot;OWNER&quot;=:V)
  10 - filter(&quot;T2&quot;.&quot;OBJECT_ID&quot;=&quot;T3&quot;.&quot;OBJECT_ID&quot;)


33 rows selected.


SQL&gt; EXEC :v:=&#039;SYS&#039;


PL/SQL procedure successfully completed.

Elapsed: 00:00:00.00
SQL&gt; SQL&gt; SET TIMING ON
SQL&gt;
SQL&gt; PROMPT Now running the same query with different bind variables (this query should take very long time)
Now running the same query with different bind variables (this query should take very long time)
SQL&gt;
SQL&gt; SELECT
  2      MIN(t1.created), MAX(t1.created)
  3  FROM
  4      t1
  5    , t2
  6    , t3
  7  WHERE
  8      t1.object_id = t2.object_id
  9  AND t2.object_id = t3.object_id
 10  AND t1.owner = :v
 11  AND t2.owner = :v
 12  AND t3.owner = :v
 13  /

MIN(T1.CR MAX(T1.CR
--------- ---------
16-SEP-05 23-FEB-10

Elapsed: 00:00:00.08
SQL&gt; SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  5vy5qjd3fsn5c, child number 2
-------------------------------------
SELECT     MIN(t1.created), MAX(t1.created) FROM     t1   , t2   , t3
WHERE     t1.object_id = t2.object_id AND t2.object_id = t3.object_id
AND t1.owner = :v AND t2.owner = :v AND t3.owner = :v

Plan hash value: 710168226

-----------------------------------------------------------------------------
&#124; Id  &#124; Operation            &#124; Name &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
-----------------------------------------------------------------------------

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT     &#124;      &#124;       &#124;       &#124;   635 (100)&#124;          &#124;
&#124;   1 &#124;  SORT AGGREGATE      &#124;      &#124;     1 &#124;    66 &#124;            &#124;          &#124;
&#124;*  2 &#124;   HASH JOIN          &#124;      &#124; 29374 &#124;  1893K&#124;   635   (1)&#124; 00:00:08 &#124;
&#124;*  3 &#124;    TABLE ACCESS FULL &#124; T3   &#124; 30485 &#124;   565K&#124;   211   (1)&#124; 00:00:03 &#124;
&#124;*  4 &#124;    HASH JOIN         &#124;      &#124; 29374 &#124;  1348K&#124;   423   (1)&#124; 00:00:06 &#124;
&#124;*  5 &#124;     TABLE ACCESS FULL&#124; T2   &#124; 29375 &#124;   545K&#124;   211   (1)&#124; 00:00:03 &#124;
&#124;*  6 &#124;     TABLE ACCESS FULL&#124; T1   &#124; 30301 &#124;   828K&#124;   211   (1)&#124; 00:00:03 &#124;
-----------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

   2 - access(&quot;T2&quot;.&quot;OBJECT_ID&quot;=&quot;T3&quot;.&quot;OBJECT_ID&quot;)
   3 - filter(&quot;T3&quot;.&quot;OWNER&quot;=:V)
   4 - access(&quot;T1&quot;.&quot;OBJECT_ID&quot;=&quot;T2&quot;.&quot;OBJECT_ID&quot;)
   5 - filter(&quot;T2&quot;.&quot;OWNER&quot;=:V)
   6 - filter(&quot;T1&quot;.&quot;OWNER&quot;=:V)


29 rows selected.

Elapsed: 00:00:00.03
SQL&gt;</description>
		<content:encoded><![CDATA[<p>I actually spent some time  to run sql scripts to demonstrate  this issue. What I found is that the only reason optimizer does not change a plan  for second execution , when performance is bad was that &#8220;ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=10;&#8221; was issued earlier. If prior to executing script with &#8216;SYS&#8217; value of a bind variable you would change  it back : &#8220;ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=100&#8242; which is a default btw, optimizer would change its plan to hash join  from nested loops. So, what is an issue? Adaptive cursor does work</p>
<p>SQL&gt; DROP TABLE t1;<br />
DROP TABLE t2;<br />
DROP TABLE t3;</p>
<p>CREATE TABLE t1 AS SELECT * FROM dba_objects;<br />
CREATE TABLE t2 AS SELECT * FROM dba_objects;<br />
CREATE TABLE t3 AS SELECT * FROM dba_objects;</p>
<p>CREATE INDEX i1 ON t1(owner);<br />
CREATE INDEX i2 ON t2(owner);<br />
CREATE INDEX i3 ON t3(owner);</p>
<p>EXEC DBMS_STATS.GATHER_TABLE_STATS(user,&#8217;T1&#8242;,cascade=&gt;TRUE, method_opt=&gt;&#8217;FOR ALL INDEXED COLUMNS SIZE 254&#8242;);<br />
EXEC DBMS_STATS.GATHER_TABLE_STATS(user,&#8217;T2&#8242;,cascade=&gt;TRUE, method_opt=&gt;&#8217;FOR ALL INDEXED COLUMNS SIZE 254&#8242;);<br />
EXEC DBMS_STATS.GATHER_TABLE_STATS(user,&#8217;T3&#8242;,cascade=&gt;TRUE, method_opt=&gt;&#8217;FOR ALL INDEXED COLUMNS SIZE 254&#8242;);</p>
<p>Table dropped.</p>
<p>Elapsed: 00:00:00.12<br />
SQL&gt;<br />
Table dropped.</p>
<p>Elapsed: 00:00:00.14<br />
SQL&gt;<br />
Table dropped.</p>
<p>Elapsed: 00:00:00.12<br />
SQL&gt; SQL&gt;<br />
Table created.</p>
<p>Elapsed: 00:00:01.00<br />
SQL&gt;<br />
Table created.</p>
<p>Elapsed: 00:00:00.93<br />
SQL&gt;<br />
Table created.</p>
<p>Elapsed: 00:00:01.32<br />
SQL&gt; SQL&gt;<br />
Index created.</p>
<p>Elapsed: 00:00:00.56<br />
SQL&gt;<br />
Index created.</p>
<p>Elapsed: 00:00:00.60<br />
SQL&gt;<br />
Index created.</p>
<p>Elapsed: 00:00:00.54<br />
SQL&gt; SQL&gt;<br />
PL/SQL procedure successfully completed.</p>
<p>Elapsed: 00:00:00.45<br />
SQL&gt;<br />
PL/SQL procedure successfully completed.</p>
<p>Elapsed: 00:00:00.46<br />
SQL&gt;<br />
PL/SQL procedure successfully completed.</p>
<p>Elapsed: 00:00:00.46<br />
SQL&gt;</p>
<p>SQL&gt; ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=10;</p>
<p>Session altered.</p>
<p>SQL&gt;<br />
SQL&gt; VAR v VARCHAR2(100)</p>
<p>SQL&gt; SQL&gt; EXEC :v:=&#8217;SCOTT&#8217;</p>
<p>SET TIMING ON</p>
<p>PL/SQL procedure successfully completed.</p>
<p>SQL&gt; SQL&gt; SQL&gt;<br />
SQL&gt; PROMPT Running query first time, this should be fast (and should use nested loops execution plan)<br />
Running query first time, this should be fast (and should use nested loops execution plan)<br />
SQL&gt;<br />
SQL&gt; SELECT<br />
  2      MIN(t1.created), MAX(t1.created)<br />
  3  FROM<br />
  4      t1<br />
  5    , t2<br />
  6    , t3<br />
  7  WHERE<br />
  8      t1.object_id = t2.object_id<br />
  9  AND t2.object_id = t3.object_id<br />
 10  AND t1.owner = :v<br />
 11  AND t2.owner = :v<br />
 12  AND t3.owner = :v<br />
 13  /</p>
<p>SET TIMING OFF</p>
<p>&#8211;SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null,&#8217;ALLSTATS LAST ADVANCED&#8217;));<br />
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null));</p>
<p>MIN(T1.CR MAX(T1.CR<br />
&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;</p>
<p>Elapsed: 00:00:00.01<br />
SQL&gt; SQL&gt; SQL&gt; SQL&gt; SQL&gt;<br />
PLAN_TABLE_OUTPUT<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;&#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;&#8212;&#8212;<br />
SQL_ID  5vy5qjd3fsn5c, child number 0<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SELECT     MIN(t1.created), MAX(t1.created) FROM     t1   , t2   , t3<br />
WHERE     t1.object_id = t2.object_id AND t2.object_id = t3.object_id<br />
AND t1.owner = :v AND t2.owner = :v AND t3.owner = :v</p>
<p>Plan hash value: 4162198323</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;-</p>
<p>PLAN_TABLE_OUTPUT<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;&#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;&#8212;&#8212;<br />
|   0 | SELECT STATEMENT                |      |       |       |     3 (100)|          |<br />
|   1 |  SORT AGGREGATE                 |      |     1 |    66 |            |          |<br />
|   2 |   NESTED LOOPS                  |      |       |       |            |          |<br />
|   3 |    NESTED LOOPS                 |      |     6 |   396 |     3   (0)| 00:00:01 |<br />
|   4 |     NESTED LOOPS                |      |     6 |   282 |     2   (0)| 00:00:01 |<br />
|   5 |      TABLE ACCESS BY INDEX ROWID| T1   |     6 |   168 |     1   (0)| 00:00:01 |<br />
|*  6 |       INDEX RANGE SCAN          | I1   |     6 |       |     1   (0)| 00:00:01 |<br />
|*  7 |      TABLE ACCESS BY INDEX ROWID| T2   |     1 |    19 |     1   (0)| 00:00:01 |<br />
|*  8 |       INDEX RANGE SCAN          | I2   |     6 |       |     1   (0)| 00:00:01 |<br />
|*  9 |     INDEX RANGE SCAN            | I3   |     6 |       |     1   (0)| 00:00:01 |<br />
|* 10 |    TABLE ACCESS BY INDEX ROWID  | T3   |     1 |    19 |     1   (0)| 00:00:01 |</p>
<p>PLAN_TABLE_OUTPUT<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;&#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;&#8212;&#8212;<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;-</p>
<p>Predicate Information (identified by operation id):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>   6 &#8211; access(&#8220;T1&#8243;.&#8221;OWNER&#8221;=:V)<br />
   7 &#8211; filter(&#8220;T1&#8243;.&#8221;OBJECT_ID&#8221;=&#8221;T2&#8243;.&#8221;OBJECT_ID&#8221;)<br />
   8 &#8211; access(&#8220;T2&#8243;.&#8221;OWNER&#8221;=:V)<br />
   9 &#8211; access(&#8220;T3&#8243;.&#8221;OWNER&#8221;=:V)<br />
  10 &#8211; filter(&#8220;T2&#8243;.&#8221;OBJECT_ID&#8221;=&#8221;T3&#8243;.&#8221;OBJECT_ID&#8221;)</p>
<p>33 rows selected.</p>
<p>SQL&gt; EXEC :v:=&#8217;SYS&#8217;</p>
<p>PL/SQL procedure successfully completed.</p>
<p>Elapsed: 00:00:00.00<br />
SQL&gt; SQL&gt; SET TIMING ON<br />
SQL&gt;<br />
SQL&gt; PROMPT Now running the same query with different bind variables (this query should take very long time)<br />
Now running the same query with different bind variables (this query should take very long time)<br />
SQL&gt;<br />
SQL&gt; SELECT<br />
  2      MIN(t1.created), MAX(t1.created)<br />
  3  FROM<br />
  4      t1<br />
  5    , t2<br />
  6    , t3<br />
  7  WHERE<br />
  8      t1.object_id = t2.object_id<br />
  9  AND t2.object_id = t3.object_id<br />
 10  AND t1.owner = :v<br />
 11  AND t2.owner = :v<br />
 12  AND t3.owner = :v<br />
 13  /</p>
<p>MIN(T1.CR MAX(T1.CR<br />
&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;<br />
16-SEP-05 23-FEB-10</p>
<p>Elapsed: 00:00:00.08<br />
SQL&gt; SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null));</p>
<p>PLAN_TABLE_OUTPUT<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;&#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;&#8212;&#8212;<br />
SQL_ID  5vy5qjd3fsn5c, child number 2<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
SELECT     MIN(t1.created), MAX(t1.created) FROM     t1   , t2   , t3<br />
WHERE     t1.object_id = t2.object_id AND t2.object_id = t3.object_id<br />
AND t1.owner = :v AND t2.owner = :v AND t3.owner = :v</p>
<p>Plan hash value: 710168226</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;&#8211;<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;&#8211;</p>
<p>PLAN_TABLE_OUTPUT<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;&#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;&#8212;&#8212;<br />
|   0 | SELECT STATEMENT     |      |       |       |   635 (100)|          |<br />
|   1 |  SORT AGGREGATE      |      |     1 |    66 |            |          |<br />
|*  2 |   HASH JOIN          |      | 29374 |  1893K|   635   (1)| 00:00:08 |<br />
|*  3 |    TABLE ACCESS FULL | T3   | 30485 |   565K|   211   (1)| 00:00:03 |<br />
|*  4 |    HASH JOIN         |      | 29374 |  1348K|   423   (1)| 00:00:06 |<br />
|*  5 |     TABLE ACCESS FULL| T2   | 29375 |   545K|   211   (1)| 00:00:03 |<br />
|*  6 |     TABLE ACCESS FULL| T1   | 30301 |   828K|   211   (1)| 00:00:03 |<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;&#8211;</p>
<p>Predicate Information (identified by operation id):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>PLAN_TABLE_OUTPUT<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;&#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;&#8212;&#8212;</p>
<p>   2 &#8211; access(&#8220;T2&#8243;.&#8221;OBJECT_ID&#8221;=&#8221;T3&#8243;.&#8221;OBJECT_ID&#8221;)<br />
   3 &#8211; filter(&#8220;T3&#8243;.&#8221;OWNER&#8221;=:V)<br />
   4 &#8211; access(&#8220;T1&#8243;.&#8221;OBJECT_ID&#8221;=&#8221;T2&#8243;.&#8221;OBJECT_ID&#8221;)<br />
   5 &#8211; filter(&#8220;T2&#8243;.&#8221;OWNER&#8221;=:V)<br />
   6 &#8211; filter(&#8220;T1&#8243;.&#8221;OWNER&#8221;=:V)</p>
<p>29 rows selected.</p>
<p>Elapsed: 00:00:00.03<br />
SQL&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris Vayntrub</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-3916</link>
		<dc:creator>Boris Vayntrub</dc:creator>
		<pubDate>Tue, 23 Feb 2010 22:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-3916</guid>
		<description>So, how to avoid  bad execution time firs time ? Can someone post a link to an article itself? Sorry, i am new to this blog.</description>
		<content:encoded><![CDATA[<p>So, how to avoid  bad execution time firs time ? Can someone post a link to an article itself? Sorry, i am new to this blog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: king4aday</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-3913</link>
		<dc:creator>king4aday</dc:creator>
		<pubDate>Tue, 23 Feb 2010 09:44:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-3913</guid>
		<description>the solution: alter system flush shared_pool :)</description>
		<content:encoded><![CDATA[<p>the solution: alter system flush shared_pool :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kellyn Pedersen</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-3775</link>
		<dc:creator>Kellyn Pedersen</dc:creator>
		<pubDate>Thu, 04 Feb 2010 05:30:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-3775</guid>
		<description>The dynamics behind this situation have been a bit challenging for me to explain to developers and managers when it&#039;s occurred in my own environments.  Luckily for me, it occurs consistently enough and I can &quot;force&quot; a fix that they realize I&#039;m not making it up!  Excellent article and indepth research into this challenging complication with the bind variable peek feature!</description>
		<content:encoded><![CDATA[<p>The dynamics behind this situation have been a bit challenging for me to explain to developers and managers when it&#8217;s occurred in my own environments.  Luckily for me, it occurs consistently enough and I can &#8220;force&#8221; a fix that they realize I&#8217;m not making it up!  Excellent article and indepth research into this challenging complication with the bind variable peek feature!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-3768</link>
		<dc:creator>Tanel Poder</dc:creator>
		<pubDate>Wed, 03 Feb 2010 09:53:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-3768</guid>
		<description>&lt;a href=&quot;#comment-3765&quot; rel=&quot;nofollow&quot;&gt;@Timur Akhmadeev&lt;/a&gt; 
Yeah, I meant adaptive cursor sharing! I wrote the adaptive bind peeking off the top of my head.. fixed now.

I haven&#039;t had a chance to read much blog entries lately, but yeah I&#039;m aware of the quality of Kerry&#039;s stuff!</description>
		<content:encoded><![CDATA[<p><a href="#comment-3765" rel="nofollow">@Timur Akhmadeev</a><br />
Yeah, I meant adaptive cursor sharing! I wrote the adaptive bind peeking off the top of my head.. fixed now.</p>
<p>I haven&#8217;t had a chance to read much blog entries lately, but yeah I&#8217;m aware of the quality of Kerry&#8217;s stuff!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/comment-page-1/#comment-3765</link>
		<dc:creator>Timur Akhmadeev</dc:creator>
		<pubDate>Tue, 02 Feb 2010 19:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595#comment-3765</guid>
		<description>&gt;Oracle 11g has Adaptive Bind Peeking, right?
Adaptive Cursor Sharing, right :)

&gt;Well no, adaptive bind variable peeking is a reactive technique – it only kicks in after the problem has happened!
Right, I&#039;m sure you&#039;ve read Kerry&#039;s &lt;a href=&quot;http://kerryosborne.oracle-guy.com/2009/06/oracle-11g-adaptive-cursor-sharing-acs/&quot; rel=&quot;nofollow&quot;&gt;post&lt;/a&gt; on this matter.</description>
		<content:encoded><![CDATA[<p>&gt;Oracle 11g has Adaptive Bind Peeking, right?<br />
Adaptive Cursor Sharing, right :)</p>
<p>&gt;Well no, adaptive bind variable peeking is a reactive technique – it only kicks in after the problem has happened!<br />
Right, I&#8217;m sure you&#8217;ve read Kerry&#8217;s <a href="http://kerryosborne.oracle-guy.com/2009/06/oracle-11g-adaptive-cursor-sharing-acs/" rel="nofollow">post</a> on this matter.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

