<?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: FBI Delete</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Mon, 20 May 2013 17:10:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Database Scene (@Database_Scene)</title>
		<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/#comment-50151</link>
		<dc:creator><![CDATA[Database Scene (@Database_Scene)]]></dc:creator>
		<pubDate>Thu, 13 Sep 2012 20:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9453#comment-50151</guid>
		<description><![CDATA[Retweeted on DS &gt;&gt; https://twitter.com/Database_Scene
Thank you Jonhathan, for all this awesome work]]></description>
		<content:encoded><![CDATA[<p>Retweeted on DS &gt;&gt; <a href="https://twitter.com/Database_Scene" rel="nofollow">https://twitter.com/Database_Scene</a><br />
Thank you Jonhathan, for all this awesome work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rsiz</title>
		<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/#comment-50137</link>
		<dc:creator><![CDATA[rsiz]]></dc:creator>
		<pubDate>Thu, 13 Sep 2012 11:47:27 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9453#comment-50137</guid>
		<description><![CDATA[SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 13 07:24:02 2012, my unpatched laptop install. And yes, they apparently omit the block access cost for the delete just as in the non-fbi at 229. Without code in hand I can only presume they do some bundling there whichever way you get a list of row ids to delete, but even then the cost with the lousy cluster factor you intentionally created should be much more. I never noticed that before, in my focus on getting the rowid list the cheapest way. Do they perhaps just calculate the lowest cost for getting the rowid list, figuring once you have the rowids the actual cost of the deletes is the same?]]></description>
		<content:encoded><![CDATA[<p>SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 13 07:24:02 2012, my unpatched laptop install. And yes, they apparently omit the block access cost for the delete just as in the non-fbi at 229. Without code in hand I can only presume they do some bundling there whichever way you get a list of row ids to delete, but even then the cost with the lousy cluster factor you intentionally created should be much more. I never noticed that before, in my focus on getting the rowid list the cheapest way. Do they perhaps just calculate the lowest cost for getting the rowid list, figuring once you have the rowids the actual cost of the deletes is the same?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/#comment-50126</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 13 Sep 2012 08:03:25 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9453#comment-50126</guid>
		<description><![CDATA[Mark,

Nice idea.

I think the reference to Alex Fatkulin&#039;s blog confirms that the &quot;first k rows&quot; feature (and even the first_rows() hint) is disabled when the optimizer is handling an update or delete - and the arithmetic of the range scan is consistent with that. But your example shows another interesting oddity - its cost ought to be 1,229, because we&#039;ve got a nested loop predicted to access the table by rowid 1,000 times at a cost of 1 per visit - but we don&#039;t multiply the rowid cost by 1,000 (and the join cardinality is only 1 - but that&#039;s another whole problem).

Which version of Oracle are you using ? I see your final predicate references sys_nc00005$ - this happens in my 11.2.0.3, but not in my 10.2.0.3; version can make a difference.]]></description>
		<content:encoded><![CDATA[<p>Mark,</p>
<p>Nice idea.</p>
<p>I think the reference to Alex Fatkulin&#8217;s blog confirms that the &#8220;first k rows&#8221; feature (and even the first_rows() hint) is disabled when the optimizer is handling an update or delete &#8211; and the arithmetic of the range scan is consistent with that. But your example shows another interesting oddity &#8211; its cost ought to be 1,229, because we&#8217;ve got a nested loop predicted to access the table by rowid 1,000 times at a cost of 1 per visit &#8211; but we don&#8217;t multiply the rowid cost by 1,000 (and the join cardinality is only 1 &#8211; but that&#8217;s another whole problem).</p>
<p>Which version of Oracle are you using ? I see your final predicate references sys_nc00005$ &#8211; this happens in my 11.2.0.3, but not in my 10.2.0.3; version can make a difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/#comment-50125</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 13 Sep 2012 07:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9453#comment-50125</guid>
		<description><![CDATA[Mohamed,
Thanks for the link.]]></description>
		<content:encoded><![CDATA[<p>Mohamed,<br />
Thanks for the link.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hourim</title>
		<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/#comment-50089</link>
		<dc:creator><![CDATA[hourim]]></dc:creator>
		<pubDate>Wed, 12 Sep 2012 07:07:45 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9453#comment-50089</guid>
		<description><![CDATA[Hi Jonathan,

You said “Whether by accident or design, it looks as if the optimizer hasn’t used the “fkr – first K rows” optimisation change to the delete statement that it applies to the select statement”

In contrast to the select statement, when rownum is present, the first K rows is not used in delete/update statements; see the following blog article for more details

http://afatkulin.blogspot.be/search?q=first_rows

Best regards]]></description>
		<content:encoded><![CDATA[<p>Hi Jonathan,</p>
<p>You said “Whether by accident or design, it looks as if the optimizer hasn’t used the “fkr – first K rows” optimisation change to the delete statement that it applies to the select statement”</p>
<p>In contrast to the select statement, when rownum is present, the first K rows is not used in delete/update statements; see the following blog article for more details</p>
<p><a href="http://afatkulin.blogspot.be/search?q=first_rows" rel="nofollow">http://afatkulin.blogspot.be/search?q=first_rows</a></p>
<p>Best regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rsiz</title>
		<link>http://jonathanlewis.wordpress.com/2012/09/11/fbi-delete/#comment-50078</link>
		<dc:creator><![CDATA[rsiz]]></dc:creator>
		<pubDate>Tue, 11 Sep 2012 21:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9453#comment-50078</guid>
		<description><![CDATA[Explicity factoring out the rowid selection from the function based index indeed has the same costing error, but presumably since the fbi is smaller than the table in your example even including the rowid, no hint is required to use the fbi. The actual cost is what we would expect. I wonder if the OP&#039;s table is so narrow it is smaller or the same number of blocks as his fbi.

[sourcecode language=&quot;css&quot;]
SQL&gt; r
  1  delete
  2  --+ gather_plan_statistics
  3  from t1 where rowid in
  4* (select rowid from t1 where (n1+1) &lt;= 100001 and rownum &lt; 1001)

1000 rows deleted.

SQL&gt; @q_xplan_allstats_cost
SQL&gt; select * from table(dbms_xplan.display_cursor(format=&gt;&#039;COST ALLSTATS LAST&#039;))
  2  /

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  86hh8r8b62qzz, child number 0
-------------------------------------
delete --+ gather_plan_statistics from t1 where rowid in (select rowid
from t1 where (n1+1) &lt;= 100001 and rownum &lt; 1001)

Plan hash value: 2244916938

&#124; Id  &#124; Operation                    &#124; Name     &#124; Starts &#124; E-Rows &#124; Cost (%CPU)&#124; A-Rows &#124;   A-Time   &#124; Buffers &#124;  OMem &#124;  1Mem &#124; Used-Mem &#124;
-------------------------------------------------------------------------------------------------------------------------------------------
&#124;   0 &#124; DELETE STATEMENT             &#124;          &#124;      1 &#124;        &#124;   229 (100)&#124;      0 &#124;00:00:00.05 &#124;    8074 &#124;       &#124;       &#124;          &#124;
&#124;   1 &#124;  DELETE                      &#124; T1       &#124;      1 &#124;        &#124;            &#124;      0 &#124;00:00:00.05 &#124;    8074 &#124;       &#124;       &#124;          &#124;
&#124;   2 &#124;   NESTED LOOPS               &#124;          &#124;      1 &#124;      1 &#124;   229   (2)&#124;   1000 &#124;00:00:00.01 &#124;     972 &#124;       &#124;       &#124;          &#124;
&#124;   3 &#124;    VIEW                      &#124; VW_NSO_1 &#124;      1 &#124;   1000 &#124;   227   (1)&#124;   1000 &#124;00:00:00.01 &#124;       5 &#124;       &#124;       &#124;          &#124;
&#124;   4 &#124;     SORT UNIQUE              &#124;          &#124;      1 &#124;      1 &#124;            &#124;   1000 &#124;00:00:00.01 &#124;       5 &#124; 73728 &#124; 73728 &#124;          &#124;
&#124;*  5 &#124;      COUNT STOPKEY           &#124;          &#124;      1 &#124;        &#124;            &#124;   1000 &#124;00:00:00.01 &#124;       5 &#124;       &#124;       &#124;          &#124;
&#124;*  6 &#124;       INDEX RANGE SCAN       &#124; T1_F1    &#124;      1 &#124;    100K&#124;   227   (1)&#124;   1000 &#124;00:00:00.01 &#124;       5 &#124;       &#124;       &#124;          &#124;
&#124;   7 &#124;    TABLE ACCESS BY USER ROWID&#124; T1       &#124;   1000 &#124;      1 &#124;     1   (0)&#124;   1000 &#124;00:00:00.01 &#124;     967 &#124;       &#124;       &#124;          &#124;
-------------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------

   5 - filter(ROWNUM&lt;1001)
   6 - access(&quot;T1&quot;.&quot;SYS_NC00005$&quot;&lt;=100001)
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Explicity factoring out the rowid selection from the function based index indeed has the same costing error, but presumably since the fbi is smaller than the table in your example even including the rowid, no hint is required to use the fbi. The actual cost is what we would expect. I wonder if the OP&#8217;s table is so narrow it is smaller or the same number of blocks as his fbi.</p>
<pre class="brush: css; title: ; notranslate">
SQL&gt; r
  1  delete
  2  --+ gather_plan_statistics
  3  from t1 where rowid in
  4* (select rowid from t1 where (n1+1) &lt;= 100001 and rownum &lt; 1001)

1000 rows deleted.

SQL&gt; @q_xplan_allstats_cost
SQL&gt; select * from table(dbms_xplan.display_cursor(format=&gt;'COST ALLSTATS LAST'))
  2  /

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  86hh8r8b62qzz, child number 0
-------------------------------------
delete --+ gather_plan_statistics from t1 where rowid in (select rowid
from t1 where (n1+1) &lt;= 100001 and rownum &lt; 1001)

Plan hash value: 2244916938

| Id  | Operation                    | Name     | Starts | E-Rows | Cost (%CPU)| A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------------------------------
|   0 | DELETE STATEMENT             |          |      1 |        |   229 (100)|      0 |00:00:00.05 |    8074 |       |       |          |
|   1 |  DELETE                      | T1       |      1 |        |            |      0 |00:00:00.05 |    8074 |       |       |          |
|   2 |   NESTED LOOPS               |          |      1 |      1 |   229   (2)|   1000 |00:00:00.01 |     972 |       |       |          |
|   3 |    VIEW                      | VW_NSO_1 |      1 |   1000 |   227   (1)|   1000 |00:00:00.01 |       5 |       |       |          |
|   4 |     SORT UNIQUE              |          |      1 |      1 |            |   1000 |00:00:00.01 |       5 | 73728 | 73728 |          |
|*  5 |      COUNT STOPKEY           |          |      1 |        |            |   1000 |00:00:00.01 |       5 |       |       |          |
|*  6 |       INDEX RANGE SCAN       | T1_F1    |      1 |    100K|   227   (1)|   1000 |00:00:00.01 |       5 |       |       |          |
|   7 |    TABLE ACCESS BY USER ROWID| T1       |   1000 |      1 |     1   (0)|   1000 |00:00:00.01 |     967 |       |       |          |
-------------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------

   5 - filter(ROWNUM&lt;1001)
   6 - access(&quot;T1&quot;.&quot;SYS_NC00005$&quot;&lt;=100001)
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
