<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tanel Poder's blog: Core IT for Geeks and Pros &#187; SQL</title>
	<atom:link href="http://blog.tanelpoder.com/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tanelpoder.com</link>
	<description>Oracle troubleshooting, internals and performance tuning</description>
	<lastBuildDate>Sat, 31 Jul 2010 05:44:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Execution plan Quiz: Shouldn&#8217;t these row sources be the other way around ;-)</title>
		<link>http://blog.tanelpoder.com/2010/04/27/execution-plan-quiz-shouldnt-these-row-sources-be-the-other-way-around/</link>
		<comments>http://blog.tanelpoder.com/2010/04/27/execution-plan-quiz-shouldnt-these-row-sources-be-the-other-way-around/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 18:58:27 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=683</guid>
		<description><![CDATA[Here&#8217;s a little trick question. Check out the execution plan below. What the hell, shouldn&#8217;t the INDEX/TABLE access be the other way around?! Also, how come it&#8217;s TABLE ACCESS FULL (and not by INDEX ROWID) in there? This question is with a little gotcha, but can you come up with a query which produced such [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little trick question. Check out the execution plan below.</p>
<p>What the hell, shouldn&#8217;t the INDEX/TABLE access be the other way around?!</p>
<p>Also, how come it&#8217;s TABLE ACCESS FULL (and not by INDEX ROWID) in there?</p>
<p>This question is with a little gotcha, but can you come up with a query which produced such plan? ;-)</p>
<pre>----------------------------------------------
| Id  | Operation          | Name   | E-Rows |
----------------------------------------------
|   0 | SELECT STATEMENT   |        |        |
|*  1 |  INDEX RANGE SCAN  | PK_EMP |      1 |
|*  2 |   TABLE ACCESS FULL| EMP    |      1 |
----------------------------------------------</pre>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F04%2F27%2Fexecution-plan-quiz-shouldnt-these-row-sources-be-the-other-way-around%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=683" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/04/27/execution-plan-quiz-shouldnt-these-row-sources-be-the-other-way-around/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Bind Variable Peeking &#8211; execution plan inefficiency</title>
		<link>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/</link>
		<comments>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 17:11:34 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=595</guid>
		<description><![CDATA[In my Beyond Oracle Wait interface article I troubleshooted a test case where an execution plan somehow went &#8220;crazy&#8221; and started burning CPU, lots of logical IOs and the query never completed. I have uploaded the test case I used to my new website, to a section where I will upload some of my demo [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAxMC8wMS8xNS9iZXlvbmQtb3JhY2xlLXdhaXQtaW50ZXJmYWNlLXBhcnQtMi8=" target=\"_blank\">Beyond Oracle Wait interface article</a> I troubleshooted a test case where an execution plan somehow went &#8220;crazy&#8221; and started burning CPU, lots of logical IOs and the query never completed.</p>
<p>I have uploaded the test case I used to my new website, to a section where I will upload some of my demo scripts which I show at my seminars (and people can download &amp; test these themselves too):</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXNlbWluYXItZGVtby1zY3JpcHRz" target=\"_blank\">http://tech.e2sn.com/oracle-seminar-demo-scripts</a></p>
<p>Basically what I do is this:</p>
<ol>
<li>I run the query with bind variable values where only a handful of rows match the filter condition. Thus Oracle picks nested loop join (and indexed access path)</li>
<li>Then I run the <em>same</em> query with different bind values, where a lot of rows match the filter condition. Oracle reuses existing execution plan (with nested loops!!!). Oracle ends up looping through a lot of blocks again and again (because nested loop visits the &#8220;right&#8221; side of the join once for <strong><em>every</em></strong> row coming from the &#8220;left&#8221; side of the join).</li>
</ol>
<p>Using nested loops over <em>lots</em> of rows is a sure way to kill your performance.</p>
<p>And an interesting thing with my script is that the problem still happens in Oracle 11.1 and 11.2 too!</p>
<p>Oracle 11g has Adaptive Cursor Sharing, right? This should take care of such a problem, right? Well no, adaptive bind variable peeking is a <em>reactive </em>technique &#8211; it only kicks in <em>after</em> the problem has happened!</p>
<p>So feel free to download the <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXNlbWluYXItZGVtby1zY3JpcHRz" target=\"_blank\">script</a>, review it and test it out!</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F02%2F02%2Fbind-variable-peeking-execution-plan-inefficiency%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=595" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/02/02/bind-variable-peeking-execution-plan-inefficiency/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>New seminars and dates announced</title>
		<link>http://blog.tanelpoder.com/2010/01/27/new-seminars-and-dates-announced/</link>
		<comments>http://blog.tanelpoder.com/2010/01/27/new-seminars-and-dates-announced/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 11:40:31 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle 11g]]></category>
		<category><![CDATA[Oracle 11gR2]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=592</guid>
		<description><![CDATA[I have been very busy over last months (as you see from the lack of blog entries). Part of the reason is that I&#8217;ve been building new seminar material and now I&#8217;m pleased to announce some first seminar dates! I have updated new seminar dates and cities in m new webpage: http://tech.e2sn.com/oracle-training-seminars From April 2010 [...]]]></description>
			<content:encoded><![CDATA[<p>I have been very busy over last months (as you see from the lack of blog entries). Part of the reason is that I&#8217;ve been building new seminar material and now I&#8217;m pleased to announce some first seminar dates!</p>
<p>I have updated new seminar dates and cities in m new webpage:</p>
<ul>
<li><strong><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXRyYWluaW5nLXNlbWluYXJz" target=\"_blank\">http://tech.e2sn.com/oracle-training-seminars</a></strong></li>
</ul>
<p>From April 2010 I offer total 3 different seminars</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXRyYWluaW5nLXNlbWluYXJz" target=\"_blank\">Advanced Oracle Troubleshooting v2.0</a> (3 days)</li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXRyYWluaW5nLXNlbWluYXJz" target=\"_blank\">Advanced Oracle SQL Tuning</a> (3 days)</li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXRyYWluaW5nLXNlbWluYXJz" target=\"_blank\">Partitioning and Parallel Execution for Performance</a> (1 day)</li>
</ul>
<p>I have rearranged the Advanced Oracle Troubleshooting class based on customer feedback, removed some content, added new content and I think this deserves a new version number, 2.0.</p>
<p>Also, I created an entirely new class <strong>Advanced Oracle SQL Tuning</strong> which should provide the same for SQL tuners that my Advanced Oracle Troubleshooting class has provided for database troubleshooters. This class will <em>not</em> start with CBO concepts and how SQL execution might work in theory, insead we will start from going very deep into understanding how Oracle <em>really</em> executes SQL execution plans and what is the data flow order and hierarchy in the execution plan tree.</p>
<p>From there we go on into learning how to read execution plans of any complexity and how to control SQL execution plans &#8211; how to make them do exactly what we want. And CBO topics will come in the end &#8211; by then the CBO fundamental concepts such as Cardinality, Density and IO/CPU Cost will make good sense and are not just some arbitrary names for some magic numbers coming from the optimizer ;-)</p>
<p>In addition, I separated Parallel Execution and Partitioning topics (which not everyone is using) into a separate 1-day seminar, <strong>Oracle Partitioning and Parallel Execution for Performance</strong>, which I usually deliver right after the 3-day SQL tuning seminar.</p>
<p>In coming days I also plan to upload some SQL tuning related content to tech.e2sn.com to show the quality of the upcoming seminar ;-)</p>
<p>So, feel free to check out the seminar dates and descriptions here:</p>
<ul>
<li><strong><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vb3JhY2xlLXRyYWluaW5nLXNlbWluYXJz" target=\"_blank\">http://tech.e2sn.com/oracle-training-seminars</a> </strong></li>
</ul>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F01%2F27%2Fnew-seminars-and-dates-announced%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=592" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/01/27/new-seminars-and-dates-announced/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>My new website tech.e2sn.com and a new application</title>
		<link>http://blog.tanelpoder.com/2010/01/18/my-new-website-tech-e2sn-com-and-a-new-application/</link>
		<comments>http://blog.tanelpoder.com/2010/01/18/my-new-website-tech-e2sn-com-and-a-new-application/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 18:45:40 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=574</guid>
		<description><![CDATA[In early January I wrote that I&#8217;m gonna start organizing the more serious and practical Oracle content into my new website and I&#8217;ll leave my blog for Oracle hacks, my (IT) observations and philosophy, general thoughts and just fun. It&#8217;s time to publish the newsite now with an application demo rototype which gives some clue [...]]]></description>
			<content:encoded><![CDATA[<p>In early January I wrote that I&#8217;m gonna start organizing the more serious and practical Oracle content into my new website and I&#8217;ll leave my blog for Oracle hacks, my (IT) observations and philosophy, general thoughts and just fun.</p>
<p>It&#8217;s time to publish the newsite now with an application <em>demo rototype</em> which gives some clue of what kind of features will there be in the secret project I&#8217;ve been working on for several months with my friend and business partner.</p>
<p>The website is located here:</p>
<h3><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20=" target=\"_blank\">http://tech.e2sn.com</a></h3>
<p>E2SN <em>does</em> have a meaning, but I&#8217;ll leave it a secret for now ( you are free to guess ;-)</p>
<p>So, there&#8217;s not much technical content at the site yet, but there&#8217;s a cool online app which you should check if you deal with SQL tuning and execution plan analysis much.</p>
<p>It&#8217;s called PlanViz, Oracle Execution Plan Visualization app, you can check it out here:</p>
<h3></h3>
<h3><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3RlY2guZTJzbi5jb20vYXBwcy9wbGFudml6Lw==" target=\"_blank\">http://tech.e2sn.com/apps/planviz</a></h3>
<p>Oh, I&#8217;ve also created something called a &#8220;Living Book&#8221; into my website, where I will write about Oracle, performance, troubleshooting, etc. There is also a place where people can request what I should write about there!</p>
<p>And that&#8217;s all for today!</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2010%2F01%2F18%2Fmy-new-website-tech-e2sn-com-and-a-new-application%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=574" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2010/01/18/my-new-website-tech-e2sn-com-and-a-new-application/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>NULL is not zero!</title>
		<link>http://blog.tanelpoder.com/2009/12/30/null-is-not-zero/</link>
		<comments>http://blog.tanelpoder.com/2009/12/30/null-is-not-zero/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 06:48:15 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=518</guid>
		<description><![CDATA[Some time ago I wrote a post about how COUNT(*) and COUNT(column) are semantically different things (link). Such queries may return different results if the column counted has NULLs in it. And the difference comes from that NULL is not a value, it&#8217;s rather a state which says &#8220;value unknown&#8221; or &#8220;no value entered&#8221;. So, [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I wrote a post about how COUNT(*) and COUNT(column) are semantically different things (<a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOS8wOC8yMS9zZWxlY3QtY291bnQtYW5kLWNvdW50Y29sdW1uLWFyZS1kaWZmZXJlbnQtdGhpbmdzLw==">link</a>). Such queries may return different results if the column counted has NULLs in it. And the difference comes from that NULL is not a value, it&#8217;s rather a state which says &#8220;value unknown&#8221; or &#8220;no value entered&#8221;.</p>
<p>So, you better understand how NULLs interact with your SQL constructs if you call yourself a DBA or a database developer ;-)</p>
<p>Here&#8217;s another example about how misunderstanding NULLs may cause your application to return different results than what was intended.</p>
<p>I will create a little table with TWO rows in it:</p>
<pre>SQL&gt; create table t(a int);
</pre>
<pre>Table created.

SQL&gt; insert into t values(<strong>1</strong>);

1 row created.

SQL&gt; insert into t values(<strong>null</strong>);

1 row created.

SQL&gt; select avg(a) from t;

 AVG(A)
----------
         1
</pre>
<p>When I take an average of the 2 values in these rows I get average of 1.</p>
<p>Now lets update the NULL (no value) to 0 (an actual value of zero).</p>
<pre>SQL&gt; update t set a=0 where a is null;

1 row updated.

SQL&gt; select avg(a) from t;

 AVG(A)
----------
        .5
</pre>
<p>As you see, as we now have an actual value in the other row (as opposed to &#8220;no value&#8221;), the AVG function takes that zero into account.</p>
<p>Hopefully this illustrates once more that NULL does <em>not</em> mean zero or any other value, it means <em>NO value</em>. If you do aggregation functions (count,avg) over NULLs then you must understand that Oracle treats NULLs as no value and doesn&#8217;t account these &#8220;no values&#8221;, thus your queries may behave differently than what your intuition might say (and yes its always good to read documentation about what exactly a given SQL construction/function does in the given database engine instead of relying on &#8220;common sense&#8221;).</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F12%2F30%2Fnull-is-not-zero%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=518" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/12/30/null-is-not-zero/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Explain Plan For command may show you the wrong execution plan &#8211; Part 1</title>
		<link>http://blog.tanelpoder.com/2009/11/17/explain-plan-for-command-may-show-you-the-wrong-execution-plan-part-1/</link>
		<comments>http://blog.tanelpoder.com/2009/11/17/explain-plan-for-command-may-show-you-the-wrong-execution-plan-part-1/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 02:33:24 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=494</guid>
		<description><![CDATA[In Oracle-L mailing list a question was asked about under which conditions can the explain plan report a wrong execution plan (not the one which was actually used when a problem happened). I replied this, but thought to show an example test case of this problem too: 1) The optimizer statistics the EXPLAIN PLAN ends [...]]]></description>
			<content:encoded><![CDATA[<p>In Oracle-L mailing list <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mcmVlbGlzdHMub3JnL3Bvc3Qvb3JhY2xlLWwvZXhwbGFpbi1wbGFuLWFuZC10aGUtcmVhbC1leGVjdXRpb24tcGxhbg==" target=\"_blank\">a question</a> was asked about under which conditions can the explain plan report a wrong execution plan (not the one which was actually used when a problem happened).</p>
<p>I replied this, but thought to show an example test case of this problem too:</p>
<blockquote><p><em>1) The optimizer statistics the EXPLAIN PLAN ends up using are different<br />
from the statistics the other session ended up using</em></p>
<p><em>2) Explain plan does not use bind variable peeking thus will not optimize<br />
for current bind variable values</em></p>
<p><em>3) Explain plan treats all bind variables as VARCHAR2, thus you ma have<br />
implicit datatype conversion happening during the plan execution, (meaning<br />
to_char,to_number functions are added around variables/columns) and this for<br />
example may make optimizer to ignore some indexes if you get unlucky.</em></p>
<p><em>&#8230;Of course explain plan doesn&#8217;t really<br />
execute the plan so the implicit datatype conversion you see is in the<br />
explained plan only, but if you actually execute the statement (with correct<br />
bind datatypes) then there&#8217;s no implicit datatype conversion. And that&#8217;s<br />
where the difference comes from&#8230;</em></p></blockquote>
<p>And here comes an example of condition number 3 above. Lets use a little bit of bad design out there and put numeric values into varchar2 columns:</p>
<pre>SQL&gt; create table t (id varchar2(10), name varchar2(100));

Table created.

SQL&gt; insert into t select to_char(object_id), object_name from dba_objects;

51449 rows created.</pre>
<p>Now we add a little index for lookup performance and gather stats:</p>
<pre>SQL&gt; create index i on t(id);

Index created.

SQL&gt; exec dbms_stats.gather_table_stats(user,'T',cascade=&gt;true);

PL/SQL procedure successfully completed.</pre>
<p>Now lets define a bind variable of NUMBER type and set a value for it:</p>
<pre>SQL&gt; var x number
SQL&gt;
SQL&gt; exec :x:=99999

PL/SQL procedure successfully completed.</pre>
<p>Now lets use &#8220;explain plan for&#8221; to estimate the execution plan:</p>
<pre>SQL&gt; <strong>explain plan for</strong>
 2  select sum(length(name)) from t where id &gt;  :x;

Explained.

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

PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------
Plan hash value: 3694077449

-------------------------------------------------------------------------------------
| Id  | Operation                    | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |      |     1 |    29 |    56   (0)| 00:00:01 |
|   1 |  SORT AGGREGATE              |      |     1 |    29 |            |          |
|   2 |   TABLE ACCESS BY INDEX ROWID| T    |  2572 | 74588 |    56   (0)| 00:00:01 |
|*  3 |    <strong>INDEX RANGE SCAN</strong>          | I    |   463 |       |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------

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

 3 - access("ID"&gt;:X)

15 rows selected.</pre>
<p>Explain plan command nicely reports that we&#8217;d be using an index range scan, which would be a good thing to do given my test data and search condition.</p>
<p>Now lets actually run the statement and see the REAL execution plan <em>actually used</em> for the execution. I&#8217;ll use dbms_xplan.display_CURSOR for this. If you don&#8217;t pass SQL_ID/child into that function it will just report the last SQL statement executed in your current session. But the key difference between the dbms_xplan.DISPLAY and DISPLAY_CURSOR is that the latter goes to library cache and fetches the <em>actual</em> SQL plan used from there. The explain plan command just reparses the statement and estimates a plan, ignoring any bind variable values and assuming that all bind variables are of type varchar2:</p>
<pre>SQL&gt; select sum(length(name)) from t where id &gt;  :x;

SUM(LENGTH(NAME))
-----------------

SQL&gt; select * from table(dbms_xplan.display_<strong>cursor</strong>);

PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------
SQL_ID  7zm570j6kj597, child number 0
-------------------------------------
select sum(length(name)) from t where id &gt;  :x

Plan hash value: 2966233522

---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |    60 (100)|          |
|   1 |  SORT AGGREGATE    |      |     1 |    29 |            |          |
|*  2 |   <strong>TABLE ACCESS FULL</strong>| T    |  2572 | 74588 |    60   (5)| 00:00:01 |
---------------------------------------------------------------------------

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

 2 - filter(<strong>TO_NUMBER</strong>("ID")&gt;:X)

19 rows selected.</pre>
<p>Whatta? We actually used a full table scan!</p>
<p>2nd part will follow soon :-)</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F11%2F17%2Fexplain-plan-for-command-may-show-you-the-wrong-execution-plan-part-1%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=494" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/11/17/explain-plan-for-command-may-show-you-the-wrong-execution-plan-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Select COUNT(*) and COUNT(column) are different things!</title>
		<link>http://blog.tanelpoder.com/2009/08/21/select-count-and-countcolumn-are-different-things/</link>
		<comments>http://blog.tanelpoder.com/2009/08/21/select-count-and-countcolumn-are-different-things/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:58:19 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=411</guid>
		<description><![CDATA[Every now and then I see someone wondering why Oracle is &#8220;returning wrong results&#8221; for some count queries when counting using COUNT(column_name) instead of COUNT(*) or COUNT(&#60;constant&#62;). Oracle is actually returning correct results, its just that sometimes the people asking the questions haven&#8217;t realized that COUNT(column) is something semantically different from COUNT(*). COUNT(*) operation counts [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then I see someone wondering why Oracle is &#8220;returning wrong results&#8221; for some count queries when counting using COUNT(column_name) instead of COUNT(*) or COUNT(&lt;constant&gt;).</p>
<p>Oracle is actually returning correct results, its just that sometimes the people asking the questions haven&#8217;t realized that COUNT(column) is something semantically different from COUNT(*).</p>
<p>COUNT(*) operation counts <strong>all rows</strong> fed to it by execution plan branch under it.</p>
<p>COUNT(column) operation on the other hand counts <strong>all non-null values</strong> <strong>in that column</strong> from rows fed to it by execution plan branch under it.</p>
<p>And here&#8217;s a little example:</p>
<p><span id="more-411"></span></p>
<pre>SQL&gt; select count(*) from v$session;

 COUNT(*)
----------
        23

SQL&gt; select count(username) from v$session;

COUNT(USERNAME)
---------------
              1  <em>&lt;&lt;-- only one non-null value in that column</em>

SQL&gt; select count(nvl(username,'blah')) from v$session; <em>&lt;&lt;-- lets replace NULLs with non-nulls</em>

COUNT(NVL(USERNAME,'BLAH'))
---------------------------
                         23</pre>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F08%2F21%2Fselect-count-and-countcolumn-are-different-things%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=411" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/08/21/select-count-and-countcolumn-are-different-things/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Scripts for showing execution plans via plain SQL and also in Oracle 9i</title>
		<link>http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/</link>
		<comments>http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/#comments</comments>
		<pubDate>Tue, 26 May 2009 20:42:05 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/</guid>
		<description><![CDATA[Hi all, Here are few scripts which allow you to query SQL execution plans and their execution statistics out from V$SQL_PLAN and V$SQL_PLAN_STATISTICS yourself. Why would you want to do this as there&#8217;s the DBMS_XPLAN.DISPLAY_CURSOR() function in Oracle 10g? Well, my scripts work also on Oracle 9.2. Also they give you better detail (and flexibility) [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>Here are few scripts which allow you to query SQL execution plans and their execution statistics out from V$SQL_PLAN and V$SQL_PLAN_STATISTICS yourself.</p>
<p>Why would you want to do this as there&#8217;s the DBMS_XPLAN.DISPLAY_CURSOR() function in Oracle 10g?</p>
<p>Well, my scripts work also on Oracle 9.2. Also they give you better detail (and flexibility) compared to DBMS_XPLAN.DISPLAY_CURSOR.</p>
<p>Of course in 9i there&#8217;s the DBMS_XPLAN.DISPLAY function which you can use in conjuction with EXPLAIN PLAN FOR command, but that approach has problems. EXPLAIN PLAN treats all bind variables as varchar2 datatype, possibly causing the reported execution plan to be different from reality. Also, if you have a long running report from last night and you run explain plan today morning, then if optimizer statistics have changed meanwhile, the explain plan command might come up with a different execution plan again, which is different from reality.</p>
<p>So that&#8217;s why in 10g we have the DBMS_XPLAN.DISPLAY_CURSOR which goes directly to required library cache child cursor and extracts (unparses) the execution plan from there. The function uses V$SQL_PLAN% views as its data source. And guess what &#8211; these views are there in version 9.2 already! And thats&#8217; where my scripts come in:</p>
<p>Here&#8217;s an example. Let&#8217;s set statistics_level=all so we get rowsource level execution stats for the cursor (note that this parameter makes your query consume much more CPU so it should only be used at session level for troubleshooting a specific performance issue):</p>
<pre><code>SQL&gt; alter session set statistics_level = all;

Session altered.

SQL&gt; select count(*) from all_users;

  COUNT(*)
----------
        36
</code></pre>
<p>I know the hash value of this query, so lets report its execution plan, directly from library cache. This is the REAL execution plan inside that child cursor, not some estimate like EXPLAIN PLAN command gives:</p>
<p><span id="more-298"></span></p>
<pre><code>SQL&gt; <strong>@xm 3416239794 %</strong>

Ch Pr   Op                                                         Objcect                        Optimizer Optim rows Optim bytes Optimizer
ld ed   ID Operation                                               Name                                Cost  from step   from step Mode
-- -- ---- ------------------------------------------------------- ------------------------------ --------- ---------- ----------- ----------
 0       0 SELECT STATEMENT                                                                              14                        ALL_ROWS
         1  SORT AGGREGATE                                                                                           1          15
   A     2   HASH JOIN                                                                                   14         36         540
   A     3    HASH JOIN                                                                                   9         36         432
         4     TABLE ACCESS FULL                                   TS$                                    5         13          39
    F    5     TABLE ACCESS FULL                                   USER$                                  3         36         324
         6    TABLE ACCESS FULL                                    TS$                                    5         13          39

7 rows selected.

Ch Op
ld ID     Predicate Information (identified by operation id):
-- ------ ----------------------------------------------------------------------------------------------------
 0     2  - access("U"."TEMPTS#"="TTS"."TS#")
       3  - access("U"."DATATS#"="DTS"."TS#")
       5  - filter("U"."TYPE#"=1)

</code></pre>
<p>XM means eXplain from Memory :)</p>
<p>As we had enabled rowsource level execution stats collection, we can use another script to report the response time and resource consumption at execution plan line level (if you&#8217;re interested how Oracle achieves this, check the last part of <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOC8wNi8xNS9hZHZhbmNlZC1vcmFjbGUtdHJvdWJsZXNob290aW5nLWd1aWRlLXBhcnQtNi11bmRlcnN0YW5kaW5nLW9yYWNsZS1leGVjdXRpb24tcGxhbnMtd2l0aC1vc19leHBsYWluLw==">this blog post</a>)</p>
<pre><code>SQL&gt; <strong>@xmsh 3416239794 %</strong>

SQL hash value:          3416239794    Cursor address:                  00000003A41E5290    |   Statement first parsed at: 2009-05-26/23:02:16  |  200 seconds ago

 Ch Pr   Op                                                         Object                           ms spent in     Estimated Real #rows  Rowsource Consistent    Current   Physical   Physical    Optimizer
 ld ed   ID Operation                                               Name                               operation   output rows   returned     starts       gets       gets      reads     writes         Cost
--- -- ---- ------------------------------------------------------- ------------------------------ ------------- ------------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
  0       0 SELECT STATEMENT                                                                                                                                                                               14
          1  SORT AGGREGATE                                                                                 2.49             1          1          1         42          0          0          0
    A     2   HASH JOIN                                                                                     2.43            36         36          1         42          0          0          0           14
    A     3    HASH JOIN                                                                                    1.87            36         36          1         24          0          0          0            9
          4     TABLE ACCESS FULL                                   TS$                                      .12            13         13          1         18          0          0          0            5
     F    5     TABLE ACCESS FULL                                   USER$                                    .06            36         36          1          6          0          0          0            3
          6    TABLE ACCESS FULL                                    TS$                                      .05            13         13          1         18          0          0          0            5

 Ch Op
 ld ID     Predicate Information (identified by operation id):
--- ------ ----------------------------------------------------------------------------------------------------
  0     2  - access("U"."TEMPTS#"="TTS"."TS#")
        3  - access("U"."DATATS#"="DTS"."TS#")
        5  - filter("U"."TYPE#"=1)

</code></pre>
<p>XMSH means eXplain from Memory with Statistics by Hash value (well it did make sense to me when I wrote the script, you can rename it to something else if you like :)</p>
<p>You may need to make your browser window pretty wide to see the full output to see all the columns reported. I normally run sqlplus in Windows cmd.exe and make the screen buffer wide, so the output doesn&#8217;t wrap.</p>
<p>If you want to read what these output columns mean, read my presentation about <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vc2VtaW5hci9zZW1pbmFyLWZpbGVzLw==">how SQL plan execution works</a>.</p>
<p>As I mentioned, the above scripts run also on Oracle 9.2 (that&#8217;s why I wrote them years ago).</p>
<p>Also there&#8217;s one more script, xms.sql which doesn&#8217;t take any parameters and shows you the execution plan of the latest SQL executed in current session. It uses v$session.prev_hash_value for determining this. However on Oracle 9.2 the prev_hash_value seems to be incorrectly reset and my script would display you wrong SQL statements execution plan. In 10g onwards Oracle has fixed this problem though. In 9i you need to identify the hash value of the statement and use xmsh.sql instead.</p>
<p>In 10g the xms works ok:</p>
<pre><code>SQL&gt; select count(*) from all_tables;

  COUNT(*)
----------
      1739

1 row selected.

SQL&gt; @xms

SQL hash value:          3565202713    Cursor address:                  00000003A4311930    |   Statement first parsed at: 2009-05-26/23:05:59  |  2 seconds ago

 Ch Pr   Op                                          Object                             ms spent   Estimated Real #rows  Rowsource Consistent    Current   Physical   Physical  Optimizer
 ld ed   ID Operation                                Name                                 in op. output rows   returned     starts       gets       gets      reads     writes       Cost
--- -- ---- ---------------------------------------- ------------------------------ ------------ ----------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
  0       0 SELECT STATEMENT                                                                                                                                                          558
          1  SORT AGGREGATE                                                               418.63           1          1          1       4559          0          1          0
     F    2   FILTER                                                                      416.78                   1739          1       4559          0          1          0
    A     3    HASH JOIN RIGHT OUTER                                                      387.23        1750       1739          1       2568          0          0          0        558
          4     TABLE ACCESS FULL                    USER$                                   .12          74         74          1          6          0          0          0          3
    A     5     HASH JOIN OUTER                                                           377.55        1750       1739          1       2562          0          0          0        555
          6      NESTED LOOPS OUTER                                                       225.00        1750       1739          1       1913          0          0          0        410
    A     7       HASH JOIN                                                               218.02        1750       1739          1       1819          0          0          0        410
          8        TABLE ACCESS FULL                 USER$                                   .11          74         74          1          6          0          0          0          3
    A     9        HASH JOIN                                                              206.61        1750       1739          1       1813          0          0          0        406
    A    10         HASH JOIN RIGHT OUTER                                                  41.63        1750       1750          1       1164          0          0          0        260
         11          TABLE ACCESS FULL               SEG$                                   5.28        5249       5249          1        156          0          0          0         35
    A    12          HASH JOIN                                                             17.97        1750       1750          1       1008          0          0          0        224
         13           MERGE JOIN CARTESIAN                                                  6.62          13         13          1         18          0          0          0          6
    A    14            HASH JOIN                                                            6.40           1          1          1          0          0          0          0          1
     F   15             FIXED TABLE FULL             X$KSPPI                                 .95           1          1          1          0          0          0          0          0
         16             FIXED TABLE FULL             X$KSPPCV                               1.45        1440       1440          1          0          0          0          0          0
         17            BUFFER SORT                                                           .20          13         13          1         18          0          0          0          6
         18             TABLE ACCESS FULL            TS$                                     .09          13         13          1         18          0          0          0          5
     F   19           TABLE ACCESS FULL              TAB$                                   3.55        1750       1750          1        990          0          0          0        218
     F   20         TABLE ACCESS FULL                OBJ$                                  55.26       53718      53716          1        649          0          0          0        146
    A    21       INDEX UNIQUE SCAN                  I_OBJ1                                 3.36           1         92       1739         94          0          0          0          0
         22      TABLE ACCESS FULL                   OBJ$                                   1.26       53728      53727          1        649          0          0          0        144
         23    NESTED LOOPS                                                                25.93           1         69        995       1991          0          1          0          2
    A    24     INDEX RANGE SCAN                     I_OBJAUTH1                            22.25           1        149        995       1991          0          1          0          2
     F   25     FIXED TABLE FULL                     X$KZSRO                                 .91           1         69        149          0          0          0          0          0
     F   26      FIXED TABLE FULL                    X$KZSPR                                 .05          14          1          1          0          0          0          0          0

 Ch Op
 ld ID     Predicate Information (identified by operation id):
--- ------ ----------------------------------------------------------------------------------------------------
  0     2  - filter(("O"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL))
        3  - access("CX"."OWNER#"="CU"."USER#")
        5  - access("T"."DATAOBJ#"="CX"."OBJ#")
        7  - access("O"."OWNER#"="U"."USER#")
        9  - access("O"."OBJ#"="T"."OBJ#")
       10  - access("T"."FILE#"="S"."FILE#" AND "T"."BLOCK#"="S"."BLOCK#" AND "T"."TS#"="S"."TS#")
       12  - access("T"."TS#"="TS"."TS#")
       14  - access("KSPPI"."INDX"="KSPPCV"."INDX")
       15  - filter("KSPPI"."KSPPINM"='_dml_monitoring_enabled')
       19  - filter(BITAND("T"."PROPERTY",1)=0)
       20  - filter(BITAND("O"."FLAGS",128)=0)
       21  - access("T"."BOBJ#"="CO"."OBJ#")
       24  - access("OA"."OBJ#"=:B1)
       25  - filter("GRANTEE#"="KZSROROL")
       26  - filter((((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49)
           OR (-"KZSPRPRV")=(-50)) AND "INST_ID"=USERENV('INSTANCE')))

</code></pre>
<p>I haven&#8217;t had a need to adjust the scripts to fix the problem what Jonathan Lewis has <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2pvbmF0aGFubGV3aXMud29yZHByZXNzLmNvbS8yMDA4LzAxLzEwL2ZpbHRlci1wbGFuLWVycm9yLw==">described earlier</a>, but it should be easily doable (just need to make sure that the connect by recursive loop is done against a materialized resultset of v$sql_plan, not the view itself to avoid excessive latching).</p>
<p>The scripts are downloadable from here:</p>
<ul>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3htLnNxbA==">xm.sql</a> &#8211; explain from Memory</li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3htc2guc3Fs">xmsh.sql</a> &#8211; eXplain from Memory lookup by Hash value</li>
<li><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9zY3JpcHRzL3htcy5zcWw=">xms.sql</a> &#8211; eXplain from Memory (latest SQL in current session)</li>
</ul>
<p><em>Update:</em></p>
<p>If you are on 10g and want to know how to convert SQL_ID&#8217;s to hash values for use with my XM scripts, read this:</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cudGFuZWxwb2Rlci5jb20vMjAwOS8wMi8yMi9zcWxfaWQtaXMtanVzdC1hLWZhbmN5LXJlcHJlc2VudGF0aW9uLW9mLWhhc2gtdmFsdWUv">http://blog.tanelpoder.com/2009/02/22/sql_id-is-just-a-fancy-representation-of-hash-value/</a></p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F05%2F26%2Fscripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=298" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/05/26/scripts-for-showing-execution-plans-via-plain-sql-and-also-in-oracle-9i/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>60000 bind variables?! Maybe it&#8217;s time to use a temporary table instead&#8230;</title>
		<link>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/</link>
		<comments>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 06:58:59 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=229</guid>
		<description><![CDATA[I just noticed a bug 8277300 filed in Metalink with following description: ORA-7445[XTYQBCB] OCCURS DURING EXECUTING SQL THAT USES 60000 BIND VARIABLES. Wow! That&#8217;s about 100 times more bind variables in a single query than what I&#8217;ve seen in past. And I thought that query was bad!!! :) I suspect this is a massive IN [...]]]></description>
			<content:encoded><![CDATA[<p>I just noticed a bug <a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9tZXRhbGluazIub3JhY2xlLmNvbS9tZXRhbGluay9wbHNxbC9tbDJfZG9jdW1lbnRzLnNob3dEb2N1bWVudD9wX2RhdGFiYXNlX2lkPUJVRyZhbXA7cF9pZD04Mjc3MzAw">8277300</a> filed in Metalink with following description:</p>
<pre><code>ORA-7445[XTYQBCB] OCCURS DURING EXECUTING SQL THAT USES <strong>60000 BIND VARIABLES</strong>.</code></pre>
<p>Wow! That&#8217;s about 100 times more bind variables in a single query than what I&#8217;ve seen in past. And I thought that query was bad!!! :)</p>
<p>I suspect this is a massive IN list passed to a query. Maybe it&#8217;s time to use a temporary table or a collection for passing in the IN values instead?</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F02%2F25%2F60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=229" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/02/25/60000-bind-variables-maybe-its-time-to-use-a-temporary-table-instead/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>New version of TPT script set uploaded</title>
		<link>http://blog.tanelpoder.com/2009/02/05/new-version-of-tpt-script-set-uploaded/</link>
		<comments>http://blog.tanelpoder.com/2009/02/05/new-version-of-tpt-script-set-uploaded/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 00:08:40 +0000</pubDate>
		<dc:creator>Tanel Poder</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Cool stuff]]></category>
		<category><![CDATA[Internals]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Oracle 11g]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.tanelpoder.com/?p=196</guid>
		<description><![CDATA[The latest version of my TPT scripts are downloadable from the link below (TPT means Tanel Poder&#8217;s Troubleshooting (or tuning) scripts ;) http://www.tanelpoder.com/files/TPT_public.zip In the zip file there are over 300 Oracle sql scripts which I use for my everyday work. Also the demo scripts I show at Advanced Oracle Troubleshooting seminar are in there as [...]]]></description>
			<content:encoded><![CDATA[<p>The latest version of my TPT scripts are downloadable from the link below (TPT means Tanel Poder&#8217;s Troubleshooting (or tuning) scripts ;)</p>
<p><a href="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy50YW5lbHBvZGVyLmNvbS9maWxlcy9UUFRfcHVibGljLnppcA==">http://www.tanelpoder.com/files/TPT_public.zip</a></p>
<p>In the zip file there are over 300 Oracle sql scripts which I use for my everyday work. Also the demo scripts I show at Advanced Oracle Troubleshooting seminar are in there as well (in aot subdirectory).</p>
<p>To my seminar attendees in New York this week: I had a typo in the TPT script download link, the link above is the correct one!</p>
<div class="facebook_like_button"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.tanelpoder.com%2F2009%2F02%2F05%2Fnew-version-of-tpt-script-set-uploaded%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="padding: 0px 0px; border:none; overflow:hidden; width:450px; height:70px;"></iframe></div> <img src="http://blog.tanelpoder.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=196" width="1" height="1" style="display: none;" /><p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://blog.tanelpoder.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://blog.tanelpoder.com/2009/02/05/new-version-of-tpt-script-set-uploaded/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
