<?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: Creating Test Scripts With Bind Variables</title>
	<atom:link href="http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/</link>
	<description>Just another Oracle blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 21:28:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Articles from Kerry Osborne &#124; Chen Guang&#039;s Blog</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-39451</link>
		<dc:creator>Articles from Kerry Osborne &#124; Chen Guang&#039;s Blog</dc:creator>
		<pubDate>Mon, 21 Mar 2011 23:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-39451</guid>
		<description>[...] Creating Test Scripts With Bind Variables July 23, 2009, 9:10 am [...]</description>
		<content:encoded><![CDATA[<p>[...] Creating Test Scripts With Bind Variables July 23, 2009, 9:10 am [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Plan stability through Upgrade to 11G- Building a test case &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-35370</link>
		<dc:creator>Plan stability through Upgrade to 11G- Building a test case &#171; Coskan&#8217;s Approach to Oracle</dc:creator>
		<pubDate>Mon, 31 Jan 2011 18:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-35370</guid>
		<description>[...] Used: http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/ [...]</description>
		<content:encoded><![CDATA[<p>[...] Used: <a href="http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/" rel="nofollow">http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-35364</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Mon, 31 Jan 2011 16:24:35 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-35364</guid>
		<description>Absolutely there are issues with this approach. The variable type issues are the biggest drawback. There is no way in SQL*Plus to mimic a Java timestamp variable for example (at least that I&#039;m aware of).</description>
		<content:encoded><![CDATA[<p>Absolutely there are issues with this approach. The variable type issues are the biggest drawback. There is no way in SQL*Plus to mimic a Java timestamp variable for example (at least that I&#8217;m aware of).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard Polarski</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-35359</link>
		<dc:creator>Bernard Polarski</dc:creator>
		<pubDate>Mon, 31 Jan 2011 15:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-35359</guid>
		<description>There is a drawback to such types of statement generators: it may works too nicely.

These statement generator may prevents you to reproduce and study implicit conversions. Since Sqlplus converts varchar2 bind to date type using  by default the value of NLS_DATE_FORMAT, you will convert nicely the timestamp to a date type, fully enjoying index access and partition pruning on your study while production obviously does not.

The problem comes from the Java representation of date with hours,minutes,seconds which is a timestamp. Sent to Oracle it results into a datatype 180 (timestamp). And for Oracle column type DATE, which has also hour,minutes, seconds, it is the table column  which is converted by the optimizer to timestamp and not the reverse(he can&#039;t loose precision). Doing so, you loose partition pruning and index access on those binds. While using statement generator, you see nothing since these binds are nicely converted to type Date, same as column table, hence no problems.</description>
		<content:encoded><![CDATA[<p>There is a drawback to such types of statement generators: it may works too nicely.</p>
<p>These statement generator may prevents you to reproduce and study implicit conversions. Since Sqlplus converts varchar2 bind to date type using  by default the value of NLS_DATE_FORMAT, you will convert nicely the timestamp to a date type, fully enjoying index access and partition pruning on your study while production obviously does not.</p>
<p>The problem comes from the Java representation of date with hours,minutes,seconds which is a timestamp. Sent to Oracle it results into a datatype 180 (timestamp). And for Oracle column type DATE, which has also hour,minutes, seconds, it is the table column  which is converted by the optimizer to timestamp and not the reverse(he can&#8217;t loose precision). Doing so, you loose partition pruning and index access on those binds. While using statement generator, you see nothing since these binds are nicely converted to type Date, same as column table, hence no problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-35353</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Mon, 31 Jan 2011 14:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-35353</guid>
		<description>Hi Bernard,

  Thanks for sharing. I&#039;ve also made some changes to mine to deal with data types a little better. When I get some time I&#039;ll have a close look at your version.

Kerry</description>
		<content:encoded><![CDATA[<p>Hi Bernard,</p>
<p>  Thanks for sharing. I&#8217;ve also made some changes to mine to deal with data types a little better. When I get some time I&#8217;ll have a close look at your version.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernard Polarski</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-35341</link>
		<dc:creator>Bernard Polarski</dc:creator>
		<pubDate>Mon, 31 Jan 2011 11:30:12 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-35341</guid>
		<description>I use this SQL in smenu and a variant of this script from V$SQL and AWR.
More work needed in the area of column date mismatched with timestamp.

&lt;pre lang=&quot;none&quot;&gt;
    set lines 32000 head off trimspool off pages 0
    break on fdate on report
   set trimspool on
select line from (
     select  decode(position, 1,
                                  &#039;-------------------------------------&#039; &#124;&#124;chr(10) &#124;&#124;
                                  &#039;-- Date :&#039;&#124;&#124;to_char(LAST_CAPTURED,&#039;YYYY-MM-DD HH24:MI:SS&#039;)&#124;&#124;chr(10)  &#124;&#124;
                                  &#039;-------------------------------------&#039; &#124;&#124;chr(10)&#124;&#124; chr(10)
                                  &#124;&#124; &#039;alter session set NLS_DATE_FORMAT=&#039;&#039;YYYY-MM-DD HH24:MI:SS&#039;&#039; ;&#039; &#124;&#124; chr(10)
                               --   &#124;&#124; &#039;alter session set NLS_TIMESTAMP_FORMAT=&#039;&#039;YYYY-MM-DD HH24:MI:SS.FFFFFF&#039;&#039; ;&#039; &#124;&#124; chr(10)
                              , chr(10)
             )&#124;&#124;
            &#039;variable &#039; &#124;&#124;
             regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;a&#039;)
             &#124;&#124;to_char(position) &#124;&#124; &#039; &#039;
            &#124;&#124; case DATATYPE
                       -- varchar2
                 when  1   then &#039;varchar2(4000)&#039; &#124;&#124; chr(10) &#124;&#124; &#039;Exec &#039;&#124;&#124;regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                 to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;  value_string &#124;&#124; &#039;&#039;&#039;;&#039;
                          -- number
                 when  2   then &#039;number&#039;         &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124;regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                 to_char(position) &#124;&#124; &#039;:=&#039;  &#124;&#124;  value_string &#124;&#124; &#039;;&#039;
                          -- date
                 when  12  then &#039;varchar2(30)&#039;   &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124; regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;
                                        decode( value_string, null,
                                                            to_char(anydata.accessdate(value_anydata),&#039;YYYY-MM-DD HH24:MI:SS&#039;) )  &#124;&#124; &#039;&#039;&#039;;&#039;
                           -- char
                 when  96  then &#039;char(3072)&#039;     &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124;regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                 to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;  value_string &#124;&#124; &#039;&#039;&#039;;&#039;
                           -- timestamp
                 when  180 then &#039;varchar2(26)&#039;   &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124;regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                 to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;
                                         decode( value_string, null,
                                                            to_char(anydata.accessTimestamp(value_anydata),&#039;YYYY-MM-DD HH24:MI:SS&#039;) ) &#124;&#124; &#039;&#039;&#039;;&#039;
                                                            --to_char(anydata.accessTimestamp(value_anydata),&#039;YYYY-MM-DD HH24:MI:SS.FFFFFF&#039;) ) &#124;&#124; &#039;&#039;&#039;;&#039;
                           -- timestampTZ
                 when  181 then &#039;varchar2(26)&#039;   &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124;regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                 to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;
                                         decode( value_string, null,
                                                            to_char(anydata.accessTimestampTZ(value_anydata),&#039;YYYY-MM-DD HH24:MI:SS&#039;) ) &#124;&#124; &#039;&#039;&#039;;&#039;
                                                            --to_char(anydata.accessTimestampTZ(value_anydata),&#039;YYYY-MM-DD HH24:MI:SS.FFFFFF&#039;) ) &#124;&#124; &#039;&#039;&#039;;&#039;
                 when  112 then &#039;CLOB&#039;           &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124;regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                  to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;  value_string &#124;&#124; &#039;&#039;&#039;;&#039;
               else
                               &#039;Varchar2(4000)&#039;  &#124;&#124; chr(10) &#124;&#124; &#039;exec &#039;&#124;&#124; regexp_replace( name,&#039;:D*[[:digit:]]*&#039;,&#039;:a&#039;) &#124;&#124;
                                  to_char(position) &#124;&#124; &#039;:=&#039;&#039;&#039;&#124;&#124;  value_string &#124;&#124; &#039;&#039;&#039;;&#039;
               end line
     from v$sql_bind_capture where sql_id = &#039;as7xqqa7711zj&#039;  and child_number = &#039;0&#039;
order by last_captured,position, child_number, position )
union all
select  regexp_replace(line,&#039;(:)D*([[:digit:]]*)&#039;,&#039;1a2&#039;)&#124;&#124;chr(10)  &#124;&#124;&#039;/&#039; line from (
select  regexp_replace(
          max(sys_connect_by_path (sql_text,&#039;{&#039;) ),
          &#039;{&#039;,&#039;&#039;) line
from (
select
        piece,   sql_text
  from v$sqltext_with_newlines where  sql_id=&#039;as7xqqa7711zj&#039;
order by 1
)
start with piece=0
connect by  piece  = prior piece + 1
)
/
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>I use this SQL in smenu and a variant of this script from V$SQL and AWR.<br />
More work needed in the area of column date mismatched with timestamp.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1607code1'); return false;">View Code</a> NONE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16071"><td class="code" id="p1607code1"><pre class="none" style="font-family:monospace;">    set lines 32000 head off trimspool off pages 0
    break on fdate on report
   set trimspool on
select line from (
     select  decode(position, 1,
                                  '-------------------------------------' ||chr(10) ||
                                  '-- Date :'||to_char(LAST_CAPTURED,'YYYY-MM-DD HH24:MI:SS')||chr(10)  ||
                                  '-------------------------------------' ||chr(10)|| chr(10)
                                  || 'alter session set NLS_DATE_FORMAT=''YYYY-MM-DD HH24:MI:SS'' ;' || chr(10)
                               --   || 'alter session set NLS_TIMESTAMP_FORMAT=''YYYY-MM-DD HH24:MI:SS.FFFFFF'' ;' || chr(10)
                              , chr(10)
             )||
            'variable ' ||
             regexp_replace( name,':D*[[:digit:]]*','a')
             ||to_char(position) || ' '
            || case DATATYPE
                       -- varchar2
                 when  1   then 'varchar2(4000)' || chr(10) || 'Exec '||regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                 to_char(position) || ':='''||  value_string || ''';'
                          -- number
                 when  2   then 'number'         || chr(10) || 'exec '||regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                 to_char(position) || ':='  ||  value_string || ';'
                          -- date
                 when  12  then 'varchar2(30)'   || chr(10) || 'exec '|| regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                to_char(position) || ':='''||
                                        decode( value_string, null,
                                                            to_char(anydata.accessdate(value_anydata),'YYYY-MM-DD HH24:MI:SS') )  || ''';'
                           -- char
                 when  96  then 'char(3072)'     || chr(10) || 'exec '||regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                 to_char(position) || ':='''||  value_string || ''';'
                           -- timestamp
                 when  180 then 'varchar2(26)'   || chr(10) || 'exec '||regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                 to_char(position) || ':='''||
                                         decode( value_string, null,
                                                            to_char(anydata.accessTimestamp(value_anydata),'YYYY-MM-DD HH24:MI:SS') ) || ''';'
                                                            --to_char(anydata.accessTimestamp(value_anydata),'YYYY-MM-DD HH24:MI:SS.FFFFFF') ) || ''';'
                           -- timestampTZ
                 when  181 then 'varchar2(26)'   || chr(10) || 'exec '||regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                 to_char(position) || ':='''||
                                         decode( value_string, null,
                                                            to_char(anydata.accessTimestampTZ(value_anydata),'YYYY-MM-DD HH24:MI:SS') ) || ''';'
                                                            --to_char(anydata.accessTimestampTZ(value_anydata),'YYYY-MM-DD HH24:MI:SS.FFFFFF') ) || ''';'
                 when  112 then 'CLOB'           || chr(10) || 'exec '||regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                  to_char(position) || ':='''||  value_string || ''';'
               else
                               'Varchar2(4000)'  || chr(10) || 'exec '|| regexp_replace( name,':D*[[:digit:]]*',':a') ||
                                  to_char(position) || ':='''||  value_string || ''';'
               end line
     from v$sql_bind_capture where sql_id = 'as7xqqa7711zj'  and child_number = '0'
order by last_captured,position, child_number, position )
union all
select  regexp_replace(line,'(:)D*([[:digit:]]*)','1a2')||chr(10)  ||'/' line from (
select  regexp_replace(
          max(sys_connect_by_path (sql_text,'{') ),
          '{','') line
from (
select
        piece,   sql_text
  from v$sqltext_with_newlines where  sql_id='as7xqqa7711zj'
order by 1
)
start with piece=0
connect by  piece  = prior piece + 1
)
/</pre></td></tr></table></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: 11.2.0.2 performance stories &#171; Coskan&#8217;s Approach to Oracle</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-34379</link>
		<dc:creator>11.2.0.2 performance stories &#171; Coskan&#8217;s Approach to Oracle</dc:creator>
		<pubDate>Mon, 17 Jan 2011 12:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-34379</guid>
		<description>[...] thanks to Kerry Osborne and his amazingly useful (I have no idea how many times it made my day) build_bind_vars script. Normally building a test case for a sql which has 100 bind variables is a nightmare but with that [...]</description>
		<content:encoded><![CDATA[<p>[...] thanks to Kerry Osborne and his amazingly useful (I have no idea how many times it made my day) build_bind_vars script. Normally building a test case for a sql which has 100 bind variables is a nightmare but with that [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Herring</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-26951</link>
		<dc:creator>Dave Herring</dc:creator>
		<pubDate>Mon, 25 Oct 2010 12:43:40 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-26951</guid>
		<description>You&#039;re absolutely correct, as usual!  The problem was thinking EXPLAIN PLAN / AUTOTRACE would peek at bind variables like the CBO.  That&#039;s why the shared pool updated stats were different then our manual tests.

Thanks for sharing all your scripts, as they helped identify the problem quickly!</description>
		<content:encoded><![CDATA[<p>You&#8217;re absolutely correct, as usual!  The problem was thinking EXPLAIN PLAN / AUTOTRACE would peek at bind variables like the CBO.  That&#8217;s why the shared pool updated stats were different then our manual tests.</p>
<p>Thanks for sharing all your scripts, as they helped identify the problem quickly!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-26577</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Fri, 22 Oct 2010 03:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-26577</guid>
		<description>Dave, 

I understand the thought process but I don&#039;t think the bind variable names have anything to do with it. 

Here are a couple of thoughts on what might be causing the problem:

1. Are there any environment settings that are different between the production runs (with the bad plan) and the tests you&#039;re doing? Try looking at X$KQLFSQCE for the optimizer settings.

2. Is it possible that data is out running stats? By that I mean, could the query that gets the bad plan have a value that is significantly outside the range of max (or min) that the stats is aware of at the point when the statement is parsed? This could also account for why replying the statement later with the same set of bind variables doesn&#039;t reproduce the bad plan. 

3. It&#039;s actually a variation on number 2. Does the bad plan happen on a regular basis (the day after switching to a new partition for example)? Could it be that stats are set to 0 rows and the first day of using the new partition causes bad plans?


By the way, what do you plan to do if you find a combination of bind variables that cause the bad plan to appear? An expedient solution might be to just force the good plan with a SQL Profile, even if it&#039;s only a temporary solution until you figure what&#039;s causing the instability. My create_sql_profile.sql script might be useful for that.

Kerry</description>
		<content:encoded><![CDATA[<p>Dave, </p>
<p>I understand the thought process but I don&#8217;t think the bind variable names have anything to do with it. </p>
<p>Here are a couple of thoughts on what might be causing the problem:</p>
<p>1. Are there any environment settings that are different between the production runs (with the bad plan) and the tests you&#8217;re doing? Try looking at X$KQLFSQCE for the optimizer settings.</p>
<p>2. Is it possible that data is out running stats? By that I mean, could the query that gets the bad plan have a value that is significantly outside the range of max (or min) that the stats is aware of at the point when the statement is parsed? This could also account for why replying the statement later with the same set of bind variables doesn&#8217;t reproduce the bad plan. </p>
<p>3. It&#8217;s actually a variation on number 2. Does the bad plan happen on a regular basis (the day after switching to a new partition for example)? Could it be that stats are set to 0 rows and the first day of using the new partition causes bad plans?</p>
<p>By the way, what do you plan to do if you find a combination of bind variables that cause the bad plan to appear? An expedient solution might be to just force the good plan with a SQL Profile, even if it&#8217;s only a temporary solution until you figure what&#8217;s causing the instability. My create_sql_profile.sql script might be useful for that.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Herring</title>
		<link>http://kerryosborne.oracle-guy.com/2009/07/creating-test-scripts-with-bind-variables/#comment-26433</link>
		<dc:creator>Dave Herring</dc:creator>
		<pubDate>Wed, 20 Oct 2010 19:04:13 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=1607#comment-26433</guid>
		<description>The problem is more likely due to me not fully understanding what&#039;s going on with bind variables.  

I&#039;m finding statements with multiple plans, 1 good 1 bad.  For the &quot;bad&quot; ones, I retrieve the bind variables used via &quot;SELECT * FROM TABLE(dbms_xplan.display_cursor(&#039;&amp;sql_id&#039;,&amp;child,&#039;+PEEKED_BINDS&#039;))&quot;, and if that indeed lists peeked bind variables, I go with them.  With those values, I use the same method you describe for creating bind variables and run the statement, then check in the shared pool for what plan was used.  I always get the &quot;good&quot; plan.

At this moment I&#039;d just like to find out what&#039;s generating the &quot;bad&quot; plan, but I can&#039;t come up with any bind values for it.  That&#039;s why I went down the road of thinking I need the exact SQL_ID.

Make sense?</description>
		<content:encoded><![CDATA[<p>The problem is more likely due to me not fully understanding what&#8217;s going on with bind variables.  </p>
<p>I&#8217;m finding statements with multiple plans, 1 good 1 bad.  For the &#8220;bad&#8221; ones, I retrieve the bind variables used via &#8220;SELECT * FROM TABLE(dbms_xplan.display_cursor(&#8216;&amp;sql_id&#8217;,&amp;child,&#8217;+PEEKED_BINDS&#8217;))&#8221;, and if that indeed lists peeked bind variables, I go with them.  With those values, I use the same method you describe for creating bind variables and run the statement, then check in the shared pool for what plan was used.  I always get the &#8220;good&#8221; plan.</p>
<p>At this moment I&#8217;d just like to find out what&#8217;s generating the &#8220;bad&#8221; plan, but I can&#8217;t come up with any bind values for it.  That&#8217;s why I went down the road of thinking I need the exact SQL_ID.</p>
<p>Make sense?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

