<?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 trouble</title>
	<atom:link href="http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/feed/" rel="self" type="application/rss+xml" />
	<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/</link>
	<description></description>
	<lastBuildDate>Thu, 02 May 2013 19:03:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1390</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Tue, 27 Dec 2011 10:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1390</guid>
		<description><![CDATA[Hi Valentin

thanks for even more simpler test case.
&lt;blockquote&gt;So it seems to be special case code in the optimizer which covers the function with CASE or NVL2 + rowid and probably eliminates access path: index (IndexOnly). My previous example works fine (with no access table) on 10.2 and goes wrong on 11.1 and 11.2.&lt;/blockquote&gt;
It might be so. Looks like the same &quot;fix&quot; was &quot;ported&quot; to 10.2.0.5 which also reports table access, while 10.2.0.4 does not.]]></description>
		<content:encoded><![CDATA[<p>Hi Valentin</p>
<p>thanks for even more simpler test case.</p>
<blockquote><p>So it seems to be special case code in the optimizer which covers the function with CASE or NVL2 + rowid and probably eliminates access path: index (IndexOnly). My previous example works fine (with no access table) on 10.2 and goes wrong on 11.1 and 11.2.</p></blockquote>
<p>It might be so. Looks like the same &#8220;fix&#8221; was &#8220;ported&#8221; to 10.2.0.5 which also reports table access, while 10.2.0.4 does not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1389</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Tue, 27 Dec 2011 05:11:13 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1389</guid>
		<description><![CDATA[There are a lot of bugs with outer join and FBI based on the functions that may return null for not null arguments on oracle support. So it seems to be special case code in the optimizer which covers the function with CASE or NVL2 + rowid and probably eliminates access path: index (IndexOnly). My previous example works fine (with no access table) on 10.2 and goes wrong on 11.1 and 11.2.]]></description>
		<content:encoded><![CDATA[<p>There are a lot of bugs with outer join and FBI based on the functions that may return null for not null arguments on oracle support. So it seems to be special case code in the optimizer which covers the function with CASE or NVL2 + rowid and probably eliminates access path: index (IndexOnly). My previous example works fine (with no access table) on 10.2 and goes wrong on 11.1 and 11.2.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valentin Nikotin</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1386</link>
		<dc:creator><![CDATA[Valentin Nikotin]]></dc:creator>
		<pubDate>Sun, 25 Dec 2011 18:00:47 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1386</guid>
		<description><![CDATA[The test case can be simpler:

[sourcecode]drop table t purge;
create table t (id number not null, x number);
create index i on t(id, nvl(x,1));

explain plan for
select a
from (select 1 id from dual) t1
   , (select id, nvl(x,1) a from (select * from t)) t2
where t1.id = t2.id(+);
select * from table(dbms_xplan.display);[/sourcecode]

And in 11.2 I got NL2 instead of CASE in 10053.

[sourcecode]SELECT NVL2(&quot;T&quot;.ROWID,NVL(&quot;T&quot;.&quot;X&quot;,1),NULL) &quot;A&quot; FROM &quot;SYS&quot;.&quot;DUAL&quot; &quot;DUAL&quot;,&quot;TEST_USER&quot;.&quot;T&quot; &quot;T&quot; WHERE &quot;T&quot;.&quot;ID&quot;(+)=1[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>The test case can be simpler:</p>
<pre class="brush: plain; title: ; notranslate">drop table t purge;
create table t (id number not null, x number);
create index i on t(id, nvl(x,1));

explain plan for
select a
from (select 1 id from dual) t1
   , (select id, nvl(x,1) a from (select * from t)) t2
where t1.id = t2.id(+);
select * from table(dbms_xplan.display);</pre>
<p>And in 11.2 I got NL2 instead of CASE in 10053.</p>
<pre class="brush: plain; title: ; notranslate">SELECT NVL2(&quot;T&quot;.ROWID,NVL(&quot;T&quot;.&quot;X&quot;,1),NULL) &quot;A&quot; FROM &quot;SYS&quot;.&quot;DUAL&quot; &quot;DUAL&quot;,&quot;TEST_USER&quot;.&quot;T&quot; &quot;T&quot; WHERE &quot;T&quot;.&quot;ID&quot;(+)=1</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1374</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Mon, 19 Dec 2011 13:24:08 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1374</guid>
		<description><![CDATA[I&#039;ve updated the post with a complete 10053 trace file.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve updated the post with a complete 10053 trace file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1372</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Mon, 19 Dec 2011 07:42:19 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1372</guid>
		<description><![CDATA[Hi Arian

thank you for feedback. I&#039;ll post the complete 10053 trace and update the post probably today.]]></description>
		<content:encoded><![CDATA[<p>Hi Arian</p>
<p>thank you for feedback. I&#8217;ll post the complete 10053 trace and update the post probably today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arian</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1364</link>
		<dc:creator><![CDATA[Arian]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 19:22:40 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1364</guid>
		<description><![CDATA[Hi Timur,

I&#039;m afraid we have a bit of a miscommunication here. I did read your original post, and I understand it very well. But I would like to know the full details of this case. You didn&#039;t post the entire 10053 trace, but claim that it is caused by case in the select statement.  Being a longer time reader of your blog, I believe your diagnosis. But it is not sufficient enough for me to understand when and where this would happen. That is why I am asking for alternatives, to see what exactly goes on. 

In your blog post you ask if somebody has seen this issue before. No, I don&#039;t know the issue. If that was the only reason for your blog post, we&#039;re done. But I&#039;d prefer your blog to be a bit more substantial, and to make your readers understand what&#039;s going on.

Just a thought.

Regards,

Arian]]></description>
		<content:encoded><![CDATA[<p>Hi Timur,</p>
<p>I&#8217;m afraid we have a bit of a miscommunication here. I did read your original post, and I understand it very well. But I would like to know the full details of this case. You didn&#8217;t post the entire 10053 trace, but claim that it is caused by case in the select statement.  Being a longer time reader of your blog, I believe your diagnosis. But it is not sufficient enough for me to understand when and where this would happen. That is why I am asking for alternatives, to see what exactly goes on. </p>
<p>In your blog post you ask if somebody has seen this issue before. No, I don&#8217;t know the issue. If that was the only reason for your blog post, we&#8217;re done. But I&#8217;d prefer your blog to be a bit more substantial, and to make your readers understand what&#8217;s going on.</p>
<p>Just a thought.</p>
<p>Regards,</p>
<p>Arian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1362</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 12:34:36 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1362</guid>
		<description><![CDATA[Thanks for that. Yes, the minimal query lacks CASE filter in the plan, although 10053 trace still shows this expression in the SELECT list. I also tried to understand at which OFE level the query starts working index only, and it looks like it does so until 8.1.7:
[sourcecode language=&quot;sql&quot;]
SQL&gt; explain plan for
  2  select /*+ optimizer_features_enable(&#039;8.1.7&#039;) */ t2.y
  3    from (select 1 id from dual) t1
  4       , (select id, y from v2 where id = :1) t2
  5   where t1.id = t2.id(+);

Explained.

SQL&gt; @xp

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Plan hash value: 250159355

--------------------------------------------------------------
&#124; Id  &#124; Operation           &#124; Name   &#124; Rows  &#124; Bytes &#124; Cost  &#124;
--------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT    &#124;        &#124;  1000 &#124; 65000 &#124;     2 &#124;
&#124;   1 &#124;  MERGE JOIN OUTER   &#124;        &#124;  1000 &#124; 65000 &#124;     2 &#124;
&#124;   2 &#124;   FAST DUAL         &#124;        &#124;     1 &#124;       &#124;     1 &#124;
&#124;   3 &#124;   VIEW              &#124;        &#124;  1000 &#124; 65000 &#124;     1 &#124;
&#124;*  4 &#124;    FILTER           &#124;        &#124;       &#124;       &#124;       &#124;
&#124;*  5 &#124;     INDEX RANGE SCAN&#124; T_INDX &#124;  1000 &#124; 13000 &#124;     1 &#124;
--------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   4 - filter(TO_NUMBER(:1)=1)
   5 - access(&quot;T&quot;.&quot;ID&quot;=TO_NUMBER(:1))

Note
-----
   - cpu costing is off (consider enabling it)

22 rows selected.

SQL&gt; explain plan for
  2  select /*+ optimizer_features_enable(&#039;9.0.0&#039;) */ t2.y
  3    from (select 1 id from dual) t1
  4       , (select id, y from v2 where id = :1) t2
  5   where t1.id = t2.id(+);

Explained.

SQL&gt; @xp

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Plan hash value: 3556404565

-----------------------------------------------------------------------
&#124; Id  &#124; Operation                    &#124; Name   &#124; Rows  &#124; Bytes &#124; Cost  &#124;
-----------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT             &#124;        &#124;     1 &#124;    20 &#124;     2 &#124;
&#124;   1 &#124;  MERGE JOIN OUTER            &#124;        &#124;     1 &#124;    20 &#124;     2 &#124;
&#124;   2 &#124;   FAST DUAL                  &#124;        &#124;     1 &#124;       &#124;     1 &#124;
&#124;   3 &#124;   TABLE ACCESS BY INDEX ROWID&#124; T      &#124;     1 &#124;    20 &#124;     1 &#124;
&#124;*  4 &#124;    INDEX RANGE SCAN          &#124; T_INDX &#124;     1 &#124;       &#124;     1 &#124;
-----------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   4 - access(&quot;T&quot;.&quot;ID&quot;(+)=TO_NUMBER(:1))
       filter(&quot;T&quot;.&quot;ID&quot;(+)=1)

Note
-----
   - cpu costing is off (consider enabling it)

21 rows selected.
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Thanks for that. Yes, the minimal query lacks CASE filter in the plan, although 10053 trace still shows this expression in the SELECT list. I also tried to understand at which OFE level the query starts working index only, and it looks like it does so until 8.1.7:</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; explain plan for
  2  select /*+ optimizer_features_enable('8.1.7') */ t2.y
  3    from (select 1 id from dual) t1
  4       , (select id, y from v2 where id = :1) t2
  5   where t1.id = t2.id(+);

Explained.

SQL&gt; @xp

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Plan hash value: 250159355

--------------------------------------------------------------
| Id  | Operation           | Name   | Rows  | Bytes | Cost  |
--------------------------------------------------------------
|   0 | SELECT STATEMENT    |        |  1000 | 65000 |     2 |
|   1 |  MERGE JOIN OUTER   |        |  1000 | 65000 |     2 |
|   2 |   FAST DUAL         |        |     1 |       |     1 |
|   3 |   VIEW              |        |  1000 | 65000 |     1 |
|*  4 |    FILTER           |        |       |       |       |
|*  5 |     INDEX RANGE SCAN| T_INDX |  1000 | 13000 |     1 |
--------------------------------------------------------------

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

   4 - filter(TO_NUMBER(:1)=1)
   5 - access(&quot;T&quot;.&quot;ID&quot;=TO_NUMBER(:1))

Note
-----
   - cpu costing is off (consider enabling it)

22 rows selected.

SQL&gt; explain plan for
  2  select /*+ optimizer_features_enable('9.0.0') */ t2.y
  3    from (select 1 id from dual) t1
  4       , (select id, y from v2 where id = :1) t2
  5   where t1.id = t2.id(+);

Explained.

SQL&gt; @xp

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------
Plan hash value: 3556404565

-----------------------------------------------------------------------
| Id  | Operation                    | Name   | Rows  | Bytes | Cost  |
-----------------------------------------------------------------------
|   0 | SELECT STATEMENT             |        |     1 |    20 |     2 |
|   1 |  MERGE JOIN OUTER            |        |     1 |    20 |     2 |
|   2 |   FAST DUAL                  |        |     1 |       |     1 |
|   3 |   TABLE ACCESS BY INDEX ROWID| T      |     1 |    20 |     1 |
|*  4 |    INDEX RANGE SCAN          | T_INDX |     1 |       |     1 |
-----------------------------------------------------------------------

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

   4 - access(&quot;T&quot;.&quot;ID&quot;(+)=TO_NUMBER(:1))
       filter(&quot;T&quot;.&quot;ID&quot;(+)=1)

Note
-----
   - cpu costing is off (consider enabling it)

21 rows selected.
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: A.</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1360</link>
		<dc:creator><![CDATA[A.]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 09:11:13 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1360</guid>
		<description><![CDATA[I just said that if you delete groupby &amp; count from your statement the execution plan will still be the same, but I expect that you will not see CASE in the transformed query. I did not propose to fix the issue. My simple point was - if you make your example more simple (without redundant &quot;group by&quot;) you maybe will have more ideas about the issue.]]></description>
		<content:encoded><![CDATA[<p>I just said that if you delete groupby &amp; count from your statement the execution plan will still be the same, but I expect that you will not see CASE in the transformed query. I did not propose to fix the issue. My simple point was &#8211; if you make your example more simple (without redundant &#8220;group by&#8221;) you maybe will have more ideas about the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1359</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 07:07:05 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1359</guid>
		<description><![CDATA[Arian

thanks for your desire to help :) to overcome the issue, but please read my &lt;a href=&quot;http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1358&quot; rel=&quot;nofollow&quot;&gt;reply&lt;/a&gt; about the purpose of this post.
&lt;blockquote&gt;But I wonder what happens when you put t2 in a with clause.&lt;/blockquote&gt;
Originally it was there; it doesn&#039;t change the way how original query behaves. However, the presence of the subquery factoring (which I don&#039;t like; I will write a post on this some day) makes the fix dependent on the Oracle version in use. But, again - this isn&#039;t my point here.]]></description>
		<content:encoded><![CDATA[<p>Arian</p>
<p>thanks for your desire to help <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  to overcome the issue, but please read my <a href="http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1358" rel="nofollow">reply</a> about the purpose of this post.</p>
<blockquote><p>But I wonder what happens when you put t2 in a with clause.</p></blockquote>
<p>Originally it was there; it doesn&#8217;t change the way how original query behaves. However, the presence of the subquery factoring (which I don&#8217;t like; I will write a post on this some day) makes the fix dependent on the Oracle version in use. But, again &#8211; this isn&#8217;t my point here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1358</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 06:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1358</guid>
		<description><![CDATA[I can only repeat: I do know how to get rid of this issue in different ways, so the &quot;fix&quot; is not what is really interesting to me. I&#039;d like to know how it&#039;s called and if there&#039;s a way to control it without any change to the test case.]]></description>
		<content:encoded><![CDATA[<p>I can only repeat: I do know how to get rid of this issue in different ways, so the &#8220;fix&#8221; is not what is really interesting to me. I&#8217;d like to know how it&#8217;s called and if there&#8217;s a way to control it without any change to the test case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arian</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1357</link>
		<dc:creator><![CDATA[Arian]]></dc:creator>
		<pubDate>Thu, 15 Dec 2011 22:06:09 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1357</guid>
		<description><![CDATA[Hi, 

thanks. That&#039;s an interesting development. But now you are materializing the view first. I don&#039;t have a database at the moment. But I wonder what happens when you put t2 in a with clause.
Would Oracle still transform it to the same view? And if so, what happens when you add a materialize hint? 

Regards,

Arian]]></description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>thanks. That&#8217;s an interesting development. But now you are materializing the view first. I don&#8217;t have a database at the moment. But I wonder what happens when you put t2 in a with clause.<br />
Would Oracle still transform it to the same view? And if so, what happens when you add a materialize hint? </p>
<p>Regards,</p>
<p>Arian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A.</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1353</link>
		<dc:creator><![CDATA[A.]]></dc:creator>
		<pubDate>Thu, 15 Dec 2011 14:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1353</guid>
		<description><![CDATA[I believe that the original problem is not in CASE, but in NVL + outer join. Did you check your query without groupby/count? And without FBI and with just usual index?]]></description>
		<content:encoded><![CDATA[<p>I believe that the original problem is not in CASE, but in NVL + outer join. Did you check your query without groupby/count? And without FBI and with just usual index?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1352</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Thu, 15 Dec 2011 14:00:24 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1352</guid>
		<description><![CDATA[Hi

I know I can do different things to get rid of this - but the point is to find out why CASE expression appears here, how this transformation is called and how to control it without query modification on Oracle parameters level.]]></description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I know I can do different things to get rid of this &#8211; but the point is to find out why CASE expression appears here, how this transformation is called and how to control it without query modification on Oracle parameters level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A.</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1351</link>
		<dc:creator><![CDATA[A.]]></dc:creator>
		<pubDate>Thu, 15 Dec 2011 13:53:53 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1351</guid>
		<description><![CDATA[Timur, Hi dude.

You can make your example more simple, &quot;group by&quot; is redundant here. And I suggest you will not see CASE there.]]></description>
		<content:encoded><![CDATA[<p>Timur, Hi dude.</p>
<p>You can make your example more simple, &#8220;group by&#8221; is redundant here. And I suggest you will not see CASE there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Timur Akhmadeev</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1350</link>
		<dc:creator><![CDATA[Timur Akhmadeev]]></dc:creator>
		<pubDate>Thu, 15 Dec 2011 12:18:14 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1350</guid>
		<description><![CDATA[Hi Arian

thanks for comment. If you try to change a subquery by adding rownum like this:
[sourcecode lang=&quot;sql&quot;]
explain plan for
select count(t2.y)
  from (select 1 id from dual) t1
     , (select id, y from v2 where id = :1 and rownum &gt; 0) t2
 where t1.id = t2.id(+)
 group by t1.id;
[/sourcecode]
You&#039;ll see that Oracle is able to avoid table access. It&#039;s still same query, same outer join - and yet no table access.

NVL is there just to apply a function, in reality there&#039;s something different.]]></description>
		<content:encoded><![CDATA[<p>Hi Arian</p>
<p>thanks for comment. If you try to change a subquery by adding rownum like this:</p>
<pre class="brush: sql; title: ; notranslate">
explain plan for
select count(t2.y)
  from (select 1 id from dual) t1
     , (select id, y from v2 where id = :1 and rownum &gt; 0) t2
 where t1.id = t2.id(+)
 group by t1.id;
</pre>
<p>You&#8217;ll see that Oracle is able to avoid table access. It&#8217;s still same query, same outer join &#8211; and yet no table access.</p>
<p>NVL is there just to apply a function, in reality there&#8217;s something different.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arian</title>
		<link>http://timurakhmadeev.wordpress.com/2011/12/14/fbi-trouble/#comment-1346</link>
		<dc:creator><![CDATA[Arian]]></dc:creator>
		<pubDate>Wed, 14 Dec 2011 19:50:10 +0000</pubDate>
		<guid isPermaLink="false">http://timurakhmadeev.wordpress.com/?p=758#comment-1346</guid>
		<description><![CDATA[Hi,

It makes sense to me.

In your first query, table T can be accessed by ID, which is the first column of the index. So the index range scan has a nice selectivity.
In your second query, you first have an outer join. This means you need all the ID values from t2. Then you count the data on t2.y. So the optimizer needs to decide the value of t2.y which is not a part of the index. So the table has to be read to check the predicate. 

Since you are using an nvl in your view, it would make more sense to query count(t2.id). The result will be the same. Even though an outer join is out of place here anyway. 

Regards,

Arian]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>It makes sense to me.</p>
<p>In your first query, table T can be accessed by ID, which is the first column of the index. So the index range scan has a nice selectivity.<br />
In your second query, you first have an outer join. This means you need all the ID values from t2. Then you count the data on t2.y. So the optimizer needs to decide the value of t2.y which is not a part of the index. So the table has to be read to check the predicate. </p>
<p>Since you are using an nvl in your view, it would make more sense to query count(t2.id). The result will be the same. Even though an outer join is out of place here anyway. </p>
<p>Regards,</p>
<p>Arian</p>
]]></content:encoded>
	</item>
</channel>
</rss>
