<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Funny Developer Tricks &#8211; first_rows(999999999)</title>
	<atom:link href="http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/feed/" rel="self" type="application/rss+xml" />
	<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/</link>
	<description>Just another Oracle blog</description>
	<lastBuildDate>Mon, 06 Feb 2012 21:28:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Charles Schultz</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-43981</link>
		<dc:creator>Charles Schultz</dc:creator>
		<pubDate>Mon, 23 May 2011 06:21:55 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-43981</guid>
		<description>Looks like this was turned into bug 11858963.</description>
		<content:encoded><![CDATA[<p>Looks like this was turned into bug 11858963.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-39041</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Thu, 17 Mar 2011 23:40:14 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-39041</guid>
		<description>Hey Charles,

Sorry for the delay – very busy these days. I don’t have a lot of time to do any detailed investigation on this issue right now but my initial thought is that any operation that can be cut short (such as a nested loop join or a table access by index rowid) would have it’s cardinality modified to N. Operations that are not able to be stopped would not.

Kerry</description>
		<content:encoded><![CDATA[<p>Hey Charles,</p>
<p>Sorry for the delay – very busy these days. I don’t have a lot of time to do any detailed investigation on this issue right now but my initial thought is that any operation that can be cut short (such as a nested loop join or a table access by index rowid) would have it’s cardinality modified to N. Operations that are not able to be stopped would not.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Schultz</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-38534</link>
		<dc:creator>Charles Schultz</dc:creator>
		<pubDate>Fri, 11 Mar 2011 15:21:55 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-38534</guid>
		<description>Kerry,

No problem. =)

The 10053 show that the table cardinality is 10. If you use FIRST_ROWS_N, the 10053 will show that the cardinality changes to match N. This seems to be a problem to me. In fact, I have an open case with Oracle about this issue and found out this morning that it is rooted in unpublished bug 4887636.

My question is, would you expect the 10053 trace to show a cardinality of 10 if you know for a fact that the table does not have 10 rows and the predicates (whether ACCESS or FILTER, or even JOINs for that matter) do not return 10 rows?</description>
		<content:encoded><![CDATA[<p>Kerry,</p>
<p>No problem. =)</p>
<p>The 10053 show that the table cardinality is 10. If you use FIRST_ROWS_N, the 10053 will show that the cardinality changes to match N. This seems to be a problem to me. In fact, I have an open case with Oracle about this issue and found out this morning that it is rooted in unpublished bug 4887636.</p>
<p>My question is, would you expect the 10053 trace to show a cardinality of 10 if you know for a fact that the table does not have 10 rows and the predicates (whether ACCESS or FILTER, or even JOINs for that matter) do not return 10 rows?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-38481</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Fri, 11 Mar 2011 01:24:31 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-38481</guid>
		<description>Hi Charles,

I&#039;m not sure I understand your first question. Could you restate it using different words? :)

I think pf probably stands for predicate filter and I think you are correct that it is calculated as K/N.

Kerry</description>
		<content:encoded><![CDATA[<p>Hi Charles,</p>
<p>I&#8217;m not sure I understand your first question. Could you restate it using different words? :)</p>
<p>I think pf probably stands for predicate filter and I think you are correct that it is calculated as K/N.</p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Schultz</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-38234</link>
		<dc:creator>Charles Schultz</dc:creator>
		<pubDate>Wed, 09 Mar 2011 22:01:07 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-38234</guid>
		<description>My thanks to you, Kerry, and Randolf and Dion Cho for putting these things out there.

I fear I may have a stupid question, but I&#039;ll ask anyway. In the 10053 trace output for first_rows(10) (above), we see:
  -----------------------------------------
  BEGIN Single Table Cardinality Estimation
  -----------------------------------------
  Table: SKEW  Alias: A
    Card: Original: 10  Rounded: 10  Computed: 10.00  Non Adjusted: 10.00


Is it expected that the estimated cardinality of a table is equal to the optimizer_mode in this case? From what I understand, first_rows is kind of &#039;fooling&#039; the CBO into thinking that a set number of rows may (or may not) be returned, but if first_rows artificially effects the cardinality of a rowsource, it would seem that more query plans would not be optimal. For example, choosing a table with an estimated cardinality of 10 when it really has 10000000 rows to be the inner table of a nested loop join.

I apologize if this was already explain and I missed it.

As a side note, what is &quot;pf&quot;. It looks like it is K/N.

Thanks for your time,</description>
		<content:encoded><![CDATA[<p>My thanks to you, Kerry, and Randolf and Dion Cho for putting these things out there.</p>
<p>I fear I may have a stupid question, but I&#8217;ll ask anyway. In the 10053 trace output for first_rows(10) (above), we see:<br />
  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
  BEGIN Single Table Cardinality Estimation<br />
  &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
  Table: SKEW  Alias: A<br />
    Card: Original: 10  Rounded: 10  Computed: 10.00  Non Adjusted: 10.00</p>
<p>Is it expected that the estimated cardinality of a table is equal to the optimizer_mode in this case? From what I understand, first_rows is kind of &#8216;fooling&#8217; the CBO into thinking that a set number of rows may (or may not) be returned, but if first_rows artificially effects the cardinality of a rowsource, it would seem that more query plans would not be optimal. For example, choosing a table with an estimated cardinality of 10 when it really has 10000000 rows to be the inner table of a nested loop join.</p>
<p>I apologize if this was already explain and I missed it.</p>
<p>As a side note, what is &#8220;pf&#8221;. It looks like it is K/N.</p>
<p>Thanks for your time,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osborne</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-9070</link>
		<dc:creator>osborne</dc:creator>
		<pubDate>Wed, 14 Apr 2010 14:32:17 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-9070</guid>
		<description>Hi Randolf,

  Yes, you are correct. The same plan was generated with or without the hint because the number was much greater than the cardinality (100M row table, first_rows_999999999). I should have saved the 10053 trace file, but no use crying over spilt milk. The quick fix was a profile to force the full table scan (ran in about 1 hour) and a recommendation for the new index on PYMET (which has now worked it&#039;s way through change control). 

Kerry</description>
		<content:encoded><![CDATA[<p>Hi Randolf,</p>
<p>  Yes, you are correct. The same plan was generated with or without the hint because the number was much greater than the cardinality (100M row table, first_rows_999999999). I should have saved the 10053 trace file, but no use crying over spilt milk. The quick fix was a profile to force the full table scan (ran in about 1 hour) and a recommendation for the new index on PYMET (which has now worked it&#8217;s way through change control). </p>
<p>Kerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Randolf Geist</title>
		<link>http://kerryosborne.oracle-guy.com/2010/04/funny-developer-tricks-first_rows/#comment-9050</link>
		<dc:creator>Randolf Geist</dc:creator>
		<pubDate>Wed, 14 Apr 2010 08:39:53 +0000</pubDate>
		<guid isPermaLink="false">http://kerryosborne.oracle-guy.com/?p=2283#comment-9050</guid>
		<description>Kerry,

my first thought was when reading the beginning of your post that the hint should be ignored due to the fact that the number of rows specified is very likely larger than the estimated cardinality of the ALL_ROWS mode.

You basically confirmed that, so my question is now: Is the bad execution plan using that index caused by the FIRST_ROWS hint / rownum predicate or not?

I assume that you ought to get the same bad plan when using the ALL_ROWS mode since the optimizer should effectively &quot;ignore&quot; the hint after determining the ALL_ROWS cardinality, but I was just looking for a confirmation - it would be interesting if you get a different execution plan although the hint ought to be &quot;ignored&quot;.

Regards,
Randolf

Oracle related stuff blog:
http://oracle-randolf.blogspot.com/

Co-author of the &quot;OakTable Expert Oracle Practices&quot; book:
http://www.apress.com/book/view/1430226684
http://www.amazon.com/Expert-Oracle-Practices-Database-Administration/dp/1430226684</description>
		<content:encoded><![CDATA[<p>Kerry,</p>
<p>my first thought was when reading the beginning of your post that the hint should be ignored due to the fact that the number of rows specified is very likely larger than the estimated cardinality of the ALL_ROWS mode.</p>
<p>You basically confirmed that, so my question is now: Is the bad execution plan using that index caused by the FIRST_ROWS hint / rownum predicate or not?</p>
<p>I assume that you ought to get the same bad plan when using the ALL_ROWS mode since the optimizer should effectively &#8220;ignore&#8221; the hint after determining the ALL_ROWS cardinality, but I was just looking for a confirmation &#8211; it would be interesting if you get a different execution plan although the hint ought to be &#8220;ignored&#8221;.</p>
<p>Regards,<br />
Randolf</p>
<p>Oracle related stuff blog:<br />
<a href="http://oracle-randolf.blogspot.com/" rel="nofollow">http://oracle-randolf.blogspot.com/</a></p>
<p>Co-author of the &#8220;OakTable Expert Oracle Practices&#8221; book:<br />
<a href="http://www.apress.com/book/view/1430226684" rel="nofollow">http://www.apress.com/book/view/1430226684</a><br />
<a href="http://www.amazon.com/Expert-Oracle-Practices-Database-Administration/dp/1430226684" rel="nofollow">http://www.amazon.com/Expert-Oracle-Practices-Database-Administration/dp/1430226684</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

