<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Rownum effects</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 19 Jun 2013 12:03:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: My Possible Pasts &#187; Blog Archive &#187; Stopkey Optimization &#8211; Part I</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37622</link>
		<dc:creator><![CDATA[My Possible Pasts &#187; Blog Archive &#187; Stopkey Optimization &#8211; Part I]]></dc:creator>
		<pubDate>Thu, 28 Oct 2010 03:28:22 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37622</guid>
		<description><![CDATA[[...] I have been seeing a lot on stopkey optimization lately. First, at the Michigan OakTable Symposium, I attended Randolf Geist&#8217;s presentation on FIRST_ROWS_N. It was a very good presentation with great examples that got me wanting to test some other cases to see the results. Second, Jonathan Lewis posted about a stopkey limitation with updates. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] I have been seeing a lot on stopkey optimization lately. First, at the Michigan OakTable Symposium, I attended Randolf Geist&#8217;s presentation on FIRST_ROWS_N. It was a very good presentation with great examples that got me wanting to test some other cases to see the results. Second, Jonathan Lewis posted about a stopkey limitation with updates. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37563</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Tue, 19 Oct 2010 10:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37563</guid>
		<description><![CDATA[Amir Riaz,

It&#039;s always worth coming up with a small collections of hypotheses to explain an anomaly. The trick is then to think up the simplest test that would eliminate some of those hypotheses.

In your case a couple of quick checks would be:
a) Does the (estimated) cost of a tablescan change from 10g to 11g 
b) Is there any difference in the more complex case when tested against 10g rather than 11g.

If you&#039;re thinking about the case in the previous comment, there&#039;s also a related question about  direct path reads for tablescans - if you&#039;re going to do an update you (probably) have to do it in the buffer cache, would this automatically ensure that Oracle won&#039;t read to the PGA for the tablescan.]]></description>
		<content:encoded><![CDATA[<p>Amir Riaz,</p>
<p>It&#8217;s always worth coming up with a small collections of hypotheses to explain an anomaly. The trick is then to think up the simplest test that would eliminate some of those hypotheses.</p>
<p>In your case a couple of quick checks would be:<br />
a) Does the (estimated) cost of a tablescan change from 10g to 11g<br />
b) Is there any difference in the more complex case when tested against 10g rather than 11g.</p>
<p>If you&#8217;re thinking about the case in the previous comment, there&#8217;s also a related question about  direct path reads for tablescans &#8211; if you&#8217;re going to do an update you (probably) have to do it in the buffer cache, would this automatically ensure that Oracle won&#8217;t read to the PGA for the tablescan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amir Riaz</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37558</link>
		<dc:creator><![CDATA[Amir Riaz]]></dc:creator>
		<pubDate>Mon, 18 Oct 2010 07:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37558</guid>
		<description><![CDATA[Jonathon,

My humble thinking is we are compare different execution paths, in update, to apply rownum &lt;= 200  result from table has to be materialized. more like in 

select *
from (select rownum ....)

My thinking here is, with oracle 11g since full table scans are done in PGA the cost of materialization has gone done and its a valid plan.

Thanks
Amir Riaz]]></description>
		<content:encoded><![CDATA[<p>Jonathon,</p>
<p>My humble thinking is we are compare different execution paths, in update, to apply rownum &lt;= 200  result from table has to be materialized. more like in </p>
<p>select *<br />
from (select rownum &#8230;.)</p>
<p>My thinking here is, with oracle 11g since full table scans are done in PGA the cost of materialization has gone done and its a valid plan.</p>
<p>Thanks<br />
Amir Riaz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37494</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 07 Oct 2010 18:43:48 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37494</guid>
		<description><![CDATA[I&#039;d have to guess that the cost of the tablescan update was lower - hence the choice; but the lower LIO count is possibly explained by: http://jonathanlewis.wordpress.com/2006/11/22/tuning-updates/]]></description>
		<content:encoded><![CDATA[<p>I&#8217;d have to guess that the cost of the tablescan update was lower &#8211; hence the choice; but the lower LIO count is possibly explained by: <a href="http://jonathanlewis.wordpress.com/2006/11/22/tuning-updates/" rel="nofollow">http://jonathanlewis.wordpress.com/2006/11/22/tuning-updates/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yuri</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37485</link>
		<dc:creator><![CDATA[Yuri]]></dc:creator>
		<pubDate>Wed, 06 Oct 2010 09:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37485</guid>
		<description><![CDATA[Please, could you explain why CBO does not decide to use index in this situation?
[sourcecode]
update /*+gather_plan_statistics*/ t1 set     small_vc =
upper(small_vc) where     id &gt; 100

Plan hash value: 2927627013

----------------------------------------------------------------------------------------------
&#124; Id  &#124; Operation          &#124; Name &#124; Starts &#124; E-Rows &#124; A-Rows &#124;   A-Time   &#124; Buffers &#124; Reads  &#124;
----------------------------------------------------------------------------------------------
&#124;   0 &#124; UPDATE STATEMENT   &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.11 &#124;     469 &#124;    172 &#124;
&#124;   1 &#124;  UPDATE            &#124; T1   &#124;      1 &#124;        &#124;      0 &#124;00:00:00.11 &#124;     469 &#124;    172 &#124;
&#124;*  2 &#124;   TABLE ACCESS FULL&#124; T1   &#124;      1 &#124;   9901 &#124;   9900 &#124;00:00:01.11 &#124;     174 &#124;    171 &#124;
----------------------------------------------------------------------------------------------
[/sourcecode]
but if CBO is forced to use the index then the LIO statistic is better
[sourcecode]
update /*+gather_plan_statistics index(t1,t1_i1)*/t1 set     small_vc =
upper(small_vc) where     id &gt; 100

Plan hash value: 3664600488

----------------------------------------------------------------------------------------------
&#124; Id  &#124; Operation         &#124; Name  &#124; Starts &#124; E-Rows &#124; A-Rows &#124;   A-Time   &#124; Buffers &#124; Reads  &#124;
----------------------------------------------------------------------------------------------
&#124;   0 &#124; UPDATE STATEMENT  &#124;       &#124;      1 &#124;        &#124;      0 &#124;00:00:00.07 &#124;     319 &#124;     22 &#124;
&#124;   1 &#124;  UPDATE           &#124; T1    &#124;      1 &#124;        &#124;      0 &#124;00:00:00.07 &#124;     319 &#124;     22 &#124;
&#124;*  2 &#124;   INDEX RANGE SCAN&#124; T1_I1 &#124;      1 &#124;   9901 &#124;   9900 &#124;00:00:00.01 &#124;      22 &#124;     22 &#124;
----------------------------------------------------------------------------------------------
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Please, could you explain why CBO does not decide to use index in this situation?</p>
<pre class="brush: plain; title: ; notranslate">
update /*+gather_plan_statistics*/ t1 set     small_vc =
upper(small_vc) where     id &amp;gt; 100

Plan hash value: 2927627013

----------------------------------------------------------------------------------------------
| Id  | Operation          | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
----------------------------------------------------------------------------------------------
|   0 | UPDATE STATEMENT   |      |      1 |        |      0 |00:00:00.11 |     469 |    172 |
|   1 |  UPDATE            | T1   |      1 |        |      0 |00:00:00.11 |     469 |    172 |
|*  2 |   TABLE ACCESS FULL| T1   |      1 |   9901 |   9900 |00:00:01.11 |     174 |    171 |
----------------------------------------------------------------------------------------------
</pre>
<p>but if CBO is forced to use the index then the LIO statistic is better</p>
<pre class="brush: plain; title: ; notranslate">
update /*+gather_plan_statistics index(t1,t1_i1)*/t1 set     small_vc =
upper(small_vc) where     id &amp;gt; 100

Plan hash value: 3664600488

----------------------------------------------------------------------------------------------
| Id  | Operation         | Name  | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
----------------------------------------------------------------------------------------------
|   0 | UPDATE STATEMENT  |       |      1 |        |      0 |00:00:00.07 |     319 |     22 |
|   1 |  UPDATE           | T1    |      1 |        |      0 |00:00:00.07 |     319 |     22 |
|*  2 |   INDEX RANGE SCAN| T1_I1 |      1 |   9901 |   9900 |00:00:00.01 |      22 |     22 |
----------------------------------------------------------------------------------------------
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: joel garry</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37480</link>
		<dc:creator><![CDATA[joel garry]]></dc:creator>
		<pubDate>Tue, 05 Oct 2010 20:32:54 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37480</guid>
		<description><![CDATA[Doc here, sorts and groupings too: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements006.htm#SQLRF50302

One of those &quot;obvious in retrospect&quot; things.  I wonder how many people expect some online inquiry with a sort to work first rows?]]></description>
		<content:encoded><![CDATA[<p>Doc here, sorts and groupings too: <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements006.htm#SQLRF50302" rel="nofollow">http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements006.htm#SQLRF50302</a></p>
<p>One of those &#8220;obvious in retrospect&#8221; things.  I wonder how many people expect some online inquiry with a sort to work first rows?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37444</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 06:01:44 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37444</guid>
		<description><![CDATA[John,

I think the intent in the original code was to avoid having to handle a very large array from  the &quot;returning&quot; clause - with the assumption that the limit wouldn&#039;t impose a significant overhead if they had to handle a small number of batches]]></description>
		<content:encoded><![CDATA[<p>John,</p>
<p>I think the intent in the original code was to avoid having to handle a very large array from  the &#8220;returning&#8221; clause &#8211; with the assumption that the limit wouldn&#8217;t impose a significant overhead if they had to handle a small number of batches</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37443</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 05:59:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37443</guid>
		<description><![CDATA[Flado,

Correct guess - I think there&#039;s even a little note somewhere in the documentation (though I don&#039;t recall where) that inserts, updates and deletes alway run all_rows and the hint is illegal in these cases.]]></description>
		<content:encoded><![CDATA[<p>Flado,</p>
<p>Correct guess &#8211; I think there&#8217;s even a little note somewhere in the documentation (though I don&#8217;t recall where) that inserts, updates and deletes alway run all_rows and the hint is illegal in these cases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Seaman</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37442</link>
		<dc:creator><![CDATA[John Seaman]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 04:59:16 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37442</guid>
		<description><![CDATA[What was the significance of adding &quot;rownum &lt;=200&quot; to the list of predicates? Was this just an attempt to make the update faster in the knowldege that there would be never more than 200 rows? Or did they just want to do 200 rows at a time because ...?]]></description>
		<content:encoded><![CDATA[<p>What was the significance of adding &#8220;rownum &lt;=200&quot; to the list of predicates? Was this just an attempt to make the update faster in the knowldege that there would be never more than 200 rows? Or did they just want to do 200 rows at a time because &#8230;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flado</title>
		<link>http://jonathanlewis.wordpress.com/2010/09/30/rownum-effects-2/#comment-37439</link>
		<dc:creator><![CDATA[Flado]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 20:46:48 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=4592#comment-37439</guid>
		<description><![CDATA[Couldn&#039;t a first_rows(200) hint do the job in a more strightforward and self-documenting fashion? Since you&#039;ve chosen no_unnest, I&#039;m guessing no, which raises the question &quot;why not?&quot;

Cheers,
Flado]]></description>
		<content:encoded><![CDATA[<p>Couldn&#8217;t a first_rows(200) hint do the job in a more strightforward and self-documenting fashion? Since you&#8217;ve chosen no_unnest, I&#8217;m guessing no, which raises the question &#8220;why not?&#8221;</p>
<p>Cheers,<br />
Flado</p>
]]></content:encoded>
	</item>
</channel>
</rss>
