<?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: Using ROWNUM in the Where Clause Causes Problems</title>
	<atom:link href="http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/feed/" rel="self" type="application/rss+xml" />
	<link>http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/</link>
	<description>Miscellaneous Random Oracle Topics: Stop, Think, ... Understand</description>
	<lastBuildDate>Thu, 13 Jun 2013 22:46:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Pavan kumar N</title>
		<link>http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/#comment-3028</link>
		<dc:creator><![CDATA[Pavan kumar N]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 18:48:23 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4726#comment-3028</guid>
		<description><![CDATA[Hi Charles...

when I executed the query in 11.2.0.1.0 the query returning rows..
&lt;pre&gt;
SQL&gt; SELECT /*+ */
  2    &quot;T1&quot;.&quot;C1&quot; &quot;C1&quot;,
  3    &quot;T1&quot;.&quot;C2&quot; &quot;C2&quot;,
  4    &quot;T1&quot;.&quot;PADDING&quot; &quot;PADDING&quot;
  5  FROM
  6    (SELECT /*+ */ DISTINCT
  7       ROWNUM &quot;RN&quot;
  8     FROM
  9        &quot;T2&quot;) &quot;VW_NSO_2&quot;,
 10     &quot;T1&quot;
 11  WHERE
 12    &quot;VW_NSO_2&quot;.&quot;RN&quot;=ROWNUM;

Execution Plan
----------------------------------------------------------
Plan hash value: 1330072140

--------------------------------------------------------------------------------
&#124; Id  &#124; Operation               &#124; Name &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
--------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT        &#124;      &#124;   100M&#124;  4196M&#124;   125K  (1)&#124; 00:25:09 &#124;
&#124;   1 &#124;  COUNT                  &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;*  2 &#124;   FILTER                &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   3 &#124;    MERGE JOIN CARTESIAN &#124;      &#124;   100M&#124;  4196M&#124;   125K  (1)&#124; 00:25:09 &#124;
&#124;   4 &#124;     VIEW                &#124;      &#124; 10000 &#124;   126K&#124;    15   (7)&#124; 00:00:01 &#124;
&#124;   5 &#124;      HASH UNIQUE        &#124;      &#124; 10000 &#124;       &#124;    15   (7)&#124; 00:00:01 &#124;
&#124;   6 &#124;       COUNT             &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   7 &#124;        TABLE ACCESS FULL&#124; T2   &#124; 10000 &#124;       &#124;    14   (0)&#124; 00:00:01 &#124;
&#124;   8 &#124;     BUFFER SORT         &#124;      &#124; 10000 &#124;   302K&#124;   125K  (1)&#124; 00:25:09 &#124;
&#124;   9 &#124;      TABLE ACCESS FULL  &#124; T1   &#124; 10000 &#124;   302K&#124;    13   (8)&#124; 00:00:01 &#124;
--------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter(&quot;VW_NSO_2&quot;.&quot;RN&quot;=ROWNUM)

Note
-----
   - dynamic sampling used for this statement (level=2)
&lt;/pre&gt;

I am rechecking the test case... i will update you soon]]></description>
		<content:encoded><![CDATA[<p>Hi Charles&#8230;</p>
<p>when I executed the query in 11.2.0.1.0 the query returning rows..</p>
<pre>
SQL&gt; SELECT /*+ */
  2    "T1"."C1" "C1",
  3    "T1"."C2" "C2",
  4    "T1"."PADDING" "PADDING"
  5  FROM
  6    (SELECT /*+ */ DISTINCT
  7       ROWNUM "RN"
  8     FROM
  9        "T2") "VW_NSO_2",
 10     "T1"
 11  WHERE
 12    "VW_NSO_2"."RN"=ROWNUM;

Execution Plan
----------------------------------------------------------
Plan hash value: 1330072140

--------------------------------------------------------------------------------
| Id  | Operation               | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |      |   100M|  4196M|   125K  (1)| 00:25:09 |
|   1 |  COUNT                  |      |       |       |            |          |
|*  2 |   FILTER                |      |       |       |            |          |
|   3 |    MERGE JOIN CARTESIAN |      |   100M|  4196M|   125K  (1)| 00:25:09 |
|   4 |     VIEW                |      | 10000 |   126K|    15   (7)| 00:00:01 |
|   5 |      HASH UNIQUE        |      | 10000 |       |    15   (7)| 00:00:01 |
|   6 |       COUNT             |      |       |       |            |          |
|   7 |        TABLE ACCESS FULL| T2   | 10000 |       |    14   (0)| 00:00:01 |
|   8 |     BUFFER SORT         |      | 10000 |   302K|   125K  (1)| 00:25:09 |
|   9 |      TABLE ACCESS FULL  | T1   | 10000 |   302K|    13   (8)| 00:00:01 |
--------------------------------------------------------------------------------

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

   2 - filter("VW_NSO_2"."RN"=ROWNUM)

Note
-----
   - dynamic sampling used for this statement (level=2)
</pre>
<p>I am rechecking the test case&#8230; i will update you soon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/#comment-3026</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 13:22:10 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4726#comment-3026</guid>
		<description><![CDATA[A couple of possibly interesting items.  The test case for this blog article was created using Oracle Database 10.2.0.2.  A 10053 trace file showed that the final query after transformations looked like the following (additional spaces and CRLF added to help readability):
&lt;pre&gt;
SELECT /*+ */
  &quot;T1&quot;.&quot;C1&quot; &quot;C1&quot;,
  &quot;T1&quot;.&quot;C2&quot; &quot;C2&quot;,
  &quot;T1&quot;.&quot;PADDING&quot; &quot;PADDING&quot;
FROM
  (SELECT /*+ */ DISTINCT
     ROWNUM &quot;RN&quot;
   FROM
     &quot;TESTUSER&quot;.&quot;T2&quot; &quot;T2&quot;) &quot;VW_NSO_2&quot;,
  &quot;TESTUSER&quot;.&quot;T1&quot; &quot;T1&quot;
WHERE
  &quot;VW_NSO_2&quot;.&quot;RN&quot;=ROWNUM
&lt;/pre&gt;

I suspect that the above is failing because ROWNUM at that point should have been undefined (similar to NULL).  Also interesting is to see that the execution plan generated by a DBMS_XPLAN, pulling the execution plan from memory, is a bit different from the output of AUTOTRACE:
&lt;pre&gt;
SQL_ID  4kk2gag8fs4jt, child number 0
-------------------------------------
SELECT T1.* FROM T1 WHERE     ROWNUM IN (      SELECT        ROWNUM RN      
FROM        T2)
 
Plan hash value: 881956856
 
----------------------------------------------------------------------------------------
&#124; Id  &#124; Operation             &#124; Name &#124; Starts &#124; E-Rows &#124; A-Rows &#124;   A-Time   &#124; Buffers &#124;
----------------------------------------------------------------------------------------
&#124;   1 &#124;  COUNT                &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.03 &#124;      49 &#124;
&#124;*  2 &#124;   FILTER              &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.03 &#124;      49 &#124;
&#124;   3 &#124;    TABLE ACCESS FULL  &#124; T1   &#124;      0 &#124;  10000 &#124;      0 &#124;00:00:00.01 &#124;       0 &#124;
&#124;*  4 &#124;    FILTER             &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.03 &#124;      49 &#124;
&#124;   5 &#124;     COUNT             &#124;      &#124;      1 &#124;        &#124;  10000 &#124;00:00:00.02 &#124;      49 &#124;
&#124;   6 &#124;      TABLE ACCESS FULL&#124; T2   &#124;      1 &#124;      1 &#124;  10000 &#124;00:00:00.01 &#124;      49 &#124;
----------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter( IS NOT NULL)
   4 - filter(ROWNUM=ROWNUM)
&lt;/pre&gt;

Notice that the filter predicate for plan ID 2 no longer shows &quot;2 - filter( EXISTS (???)&quot;, but instead shows &quot;2 - filter( IS NOT NULL)&quot;, which I believe means that no rows can be returned.  Adding a NO_QUERY_TRANSFORMATION hint does not alter the generated execution plan.

Now, repeat the test on Oracle Database 11.1.0.7.  AUTOTRACE outputs an execution plan that looks like this:
&lt;pre&gt;
Execution Plan
----------------------------------------------------------
Plan hash value: 881956856

------------------------------------------------------------------------------
&#124; Id  &#124; Operation             &#124; Name &#124; Rows  &#124; Bytes &#124; Cost (%CPU)&#124; Time     &#124;
------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT      &#124;      &#124;   100M&#124;  2574M&#124;    10   (0)&#124; 00:00:01 &#124;
&#124;   1 &#124;  COUNT                &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;*  2 &#124;   FILTER              &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   3 &#124;    TABLE ACCESS FULL  &#124; T1   &#124; 10000 &#124;   263K&#124;     8   (0)&#124; 00:00:01 &#124;
&#124;*  4 &#124;    FILTER             &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   5 &#124;     COUNT             &#124;      &#124;       &#124;       &#124;            &#124;          &#124;
&#124;   6 &#124;      TABLE ACCESS FULL&#124; T2   &#124;     1 &#124;       &#124;     2   (0)&#124; 00:00:01 &#124;
------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter( EXISTS (&lt;not feasible&gt;)
   4 - filter(ROWNUM=ROWNUM)
&lt;/pre&gt;

The filter predicate &quot;2 - filter( EXISTS (???)&quot; that had appeared in the output from 10.2.0.2 changed to &quot;2 - filter( EXISTS ()&quot; .  The DBMS_XPLAN output looks like this on 11.1.0.7 (same as 10.2.0.2):
&lt;pre&gt;
SQL_ID  6ywscwr5ambz0, child number 0
-------------------------------------
SELECT /*+ */ T1.* FROM T1 WHERE     ROWNUM IN (      SELECT        
ROWNUM RN      FROM        T2)
 
Plan hash value: 881956856
 
----------------------------------------------------------------------------------------
&#124; Id  &#124; Operation             &#124; Name &#124; Starts &#124; E-Rows &#124; A-Rows &#124;   A-Time   &#124; Buffers &#124;
----------------------------------------------------------------------------------------
&#124;   0 &#124; SELECT STATEMENT      &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.01 &#124;      49 &#124;
&#124;   1 &#124;  COUNT                &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.01 &#124;      49 &#124;
&#124;*  2 &#124;   FILTER              &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.01 &#124;      49 &#124;
&#124;   3 &#124;    TABLE ACCESS FULL  &#124; T1   &#124;      0 &#124;  10000 &#124;      0 &#124;00:00:00.01 &#124;       0 &#124;
&#124;*  4 &#124;    FILTER             &#124;      &#124;      1 &#124;        &#124;      0 &#124;00:00:00.01 &#124;      49 &#124;
&#124;   5 &#124;     COUNT             &#124;      &#124;      1 &#124;        &#124;  10000 &#124;00:00:00.01 &#124;      49 &#124;
&#124;   6 &#124;      TABLE ACCESS FULL&#124; T2   &#124;      1 &#124;      1 &#124;  10000 &#124;00:00:00.01 &#124;      49 &#124;
----------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter( IS NOT NULL)
   4 - filter(ROWNUM=ROWNUM)
&lt;/pre&gt;

I think that we have to keep in mind that ROWNUM does not have a value (is NULL?) until the result row source is generated, and any equality comparison with a NULL is false.

If someone else has a better explanation - please feel free to post a comment.

&lt;em&gt;Edit: I just noticed that the &lt;not feasible&gt; did not display in the filter predicates.&lt;/em&gt;]]></description>
		<content:encoded><![CDATA[<p>A couple of possibly interesting items.  The test case for this blog article was created using Oracle Database 10.2.0.2.  A 10053 trace file showed that the final query after transformations looked like the following (additional spaces and CRLF added to help readability):</p>
<pre>
SELECT /*+ */
  "T1"."C1" "C1",
  "T1"."C2" "C2",
  "T1"."PADDING" "PADDING"
FROM
  (SELECT /*+ */ DISTINCT
     ROWNUM "RN"
   FROM
     "TESTUSER"."T2" "T2") "VW_NSO_2",
  "TESTUSER"."T1" "T1"
WHERE
  "VW_NSO_2"."RN"=ROWNUM
</pre>
<p>I suspect that the above is failing because ROWNUM at that point should have been undefined (similar to NULL).  Also interesting is to see that the execution plan generated by a DBMS_XPLAN, pulling the execution plan from memory, is a bit different from the output of AUTOTRACE:</p>
<pre>
SQL_ID  4kk2gag8fs4jt, child number 0
-------------------------------------
SELECT T1.* FROM T1 WHERE     ROWNUM IN (      SELECT        ROWNUM RN      
FROM        T2)
 
Plan hash value: 881956856
 
----------------------------------------------------------------------------------------
| Id  | Operation             | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
----------------------------------------------------------------------------------------
|   1 |  COUNT                |      |      1 |        |      0 |00:00:00.03 |      49 |
|*  2 |   FILTER              |      |      1 |        |      0 |00:00:00.03 |      49 |
|   3 |    TABLE ACCESS FULL  | T1   |      0 |  10000 |      0 |00:00:00.01 |       0 |
|*  4 |    FILTER             |      |      1 |        |      0 |00:00:00.03 |      49 |
|   5 |     COUNT             |      |      1 |        |  10000 |00:00:00.02 |      49 |
|   6 |      TABLE ACCESS FULL| T2   |      1 |      1 |  10000 |00:00:00.01 |      49 |
----------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter( IS NOT NULL)
   4 - filter(ROWNUM=ROWNUM)
</pre>
<p>Notice that the filter predicate for plan ID 2 no longer shows &#8220;2 &#8211; filter( EXISTS (???)&#8221;, but instead shows &#8220;2 &#8211; filter( IS NOT NULL)&#8221;, which I believe means that no rows can be returned.  Adding a NO_QUERY_TRANSFORMATION hint does not alter the generated execution plan.</p>
<p>Now, repeat the test on Oracle Database 11.1.0.7.  AUTOTRACE outputs an execution plan that looks like this:</p>
<pre>
Execution Plan
----------------------------------------------------------
Plan hash value: 881956856

------------------------------------------------------------------------------
| Id  | Operation             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |      |   100M|  2574M|    10   (0)| 00:00:01 |
|   1 |  COUNT                |      |       |       |            |          |
|*  2 |   FILTER              |      |       |       |            |          |
|   3 |    TABLE ACCESS FULL  | T1   | 10000 |   263K|     8   (0)| 00:00:01 |
|*  4 |    FILTER             |      |       |       |            |          |
|   5 |     COUNT             |      |       |       |            |          |
|   6 |      TABLE ACCESS FULL| T2   |     1 |       |     2   (0)| 00:00:01 |
------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter( EXISTS (&lt;not feasible&gt;)
   4 - filter(ROWNUM=ROWNUM)
</pre>
<p>The filter predicate &#8220;2 &#8211; filter( EXISTS (???)&#8221; that had appeared in the output from 10.2.0.2 changed to &#8220;2 &#8211; filter( EXISTS ()&#8221; .  The DBMS_XPLAN output looks like this on 11.1.0.7 (same as 10.2.0.2):</p>
<pre>
SQL_ID  6ywscwr5ambz0, child number 0
-------------------------------------
SELECT /*+ */ T1.* FROM T1 WHERE     ROWNUM IN (      SELECT        
ROWNUM RN      FROM        T2)
 
Plan hash value: 881956856
 
----------------------------------------------------------------------------------------
| Id  | Operation             | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |      |      1 |        |      0 |00:00:00.01 |      49 |
|   1 |  COUNT                |      |      1 |        |      0 |00:00:00.01 |      49 |
|*  2 |   FILTER              |      |      1 |        |      0 |00:00:00.01 |      49 |
|   3 |    TABLE ACCESS FULL  | T1   |      0 |  10000 |      0 |00:00:00.01 |       0 |
|*  4 |    FILTER             |      |      1 |        |      0 |00:00:00.01 |      49 |
|   5 |     COUNT             |      |      1 |        |  10000 |00:00:00.01 |      49 |
|   6 |      TABLE ACCESS FULL| T2   |      1 |      1 |  10000 |00:00:00.01 |      49 |
----------------------------------------------------------------------------------------
 
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter( IS NOT NULL)
   4 - filter(ROWNUM=ROWNUM)
</pre>
<p>I think that we have to keep in mind that ROWNUM does not have a value (is NULL?) until the result row source is generated, and any equality comparison with a NULL is false.</p>
<p>If someone else has a better explanation &#8211; please feel free to post a comment.</p>
<p><em>Edit: I just noticed that the &lt;not feasible&gt; did not display in the filter predicates.</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavan Kumar N</title>
		<link>http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/#comment-3024</link>
		<dc:creator><![CDATA[Pavan Kumar N]]></dc:creator>
		<pubDate>Tue, 05 Apr 2011 06:00:32 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4726#comment-3024</guid>
		<description><![CDATA[Hi charles,

It was very nice interesting concept/demo you have put forward to discuss. I have gone through the demo which you stated across, perhaps in the example you have utilized across the &quot;EXISTS&quot; operator across T1 and T2 and results in zero rows. If check basic thing, rownum does assigns the rowvalue numeric value for the rows which get satisfies the &quot;where&quot; criteria of segment and it that satisfies then results into number assigned to Rownum. Looking into that concept the rownum=rownum does results into zero rows (Optimizer does have statistics and expected to scan 10000 rows and it does - good thing we need to understand the where clause or filter predicate on which rownum purely depends on).  If you consider the other test cases of In and inline view, the columns/rows apart from rownum does return and satisfies the criteria. 
let me know your comments.. too !!]]></description>
		<content:encoded><![CDATA[<p>Hi charles,</p>
<p>It was very nice interesting concept/demo you have put forward to discuss. I have gone through the demo which you stated across, perhaps in the example you have utilized across the &#8220;EXISTS&#8221; operator across T1 and T2 and results in zero rows. If check basic thing, rownum does assigns the rowvalue numeric value for the rows which get satisfies the &#8220;where&#8221; criteria of segment and it that satisfies then results into number assigned to Rownum. Looking into that concept the rownum=rownum does results into zero rows (Optimizer does have statistics and expected to scan 10000 rows and it does &#8211; good thing we need to understand the where clause or filter predicate on which rownum purely depends on).  If you consider the other test cases of In and inline view, the columns/rows apart from rownum does return and satisfies the criteria.<br />
let me know your comments.. too !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Hooper</title>
		<link>http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/#comment-3020</link>
		<dc:creator><![CDATA[Charles Hooper]]></dc:creator>
		<pubDate>Mon, 04 Apr 2011 17:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4726#comment-3020</guid>
		<description><![CDATA[Interesting - thanks for providing the link.  Do you think that the number wrapped around 0 once it hit 4294967296-1 (multiple rows with ROWNUM values of 1, 2, 3, etc.)?

Partially related old news to this article, ROWNUM can lead to poor execution plans in Oracle Database release versions prior to 11.2.0.1:
http://hoopercharles.wordpress.com/2009/12/09/sql-%e2%80%93-bad-execution-plan-caused-by-rownum-row_number-is-possible-fix/]]></description>
		<content:encoded><![CDATA[<p>Interesting &#8211; thanks for providing the link.  Do you think that the number wrapped around 0 once it hit 4294967296-1 (multiple rows with ROWNUM values of 1, 2, 3, etc.)?</p>
<p>Partially related old news to this article, ROWNUM can lead to poor execution plans in Oracle Database release versions prior to 11.2.0.1:<br />
<a href="http://hoopercharles.wordpress.com/2009/12/09/sql-%e2%80%93-bad-execution-plan-caused-by-rownum-row_number-is-possible-fix/" rel="nofollow">http://hoopercharles.wordpress.com/2009/12/09/sql-%e2%80%93-bad-execution-plan-caused-by-rownum-row_number-is-possible-fix/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://hoopercharles.wordpress.com/2011/04/04/using-rownum-in-the-where-clause-causes-problems/#comment-3019</link>
		<dc:creator><![CDATA[Tanel Poder]]></dc:creator>
		<pubDate>Mon, 04 Apr 2011 13:33:35 +0000</pubDate>
		<guid isPermaLink="false">http://hoopercharles.wordpress.com/?p=4726#comment-3019</guid>
		<description><![CDATA[Yeah, ROWNUM is just a run-time variable, incremented as rows pass through the COUNT STOPKEY row source. Interestingly it&#039;s just an UB4 datatype, so the max rownum is around 4 billion (2^32).

So, queries having WHERE ROWNUM &lt; 5 000 000 000 would actually return wrong results (only 4 Billion rows are returned, then the COUNT STOPKEY rowsource silently bails out):

http://blog.tanelpoder.com/2010/10/25/count-stopkey-operation-the-where-rownum/

Not that this is relevant to everyday operations, but I discovered this when moving tens of billions of rows onto an Exadata cluster...]]></description>
		<content:encoded><![CDATA[<p>Yeah, ROWNUM is just a run-time variable, incremented as rows pass through the COUNT STOPKEY row source. Interestingly it&#8217;s just an UB4 datatype, so the max rownum is around 4 billion (2^32).</p>
<p>So, queries having WHERE ROWNUM &lt; 5 000 000 000 would actually return wrong results (only 4 Billion rows are returned, then the COUNT STOPKEY rowsource silently bails out):</p>
<p><a href="http://blog.tanelpoder.com/2010/10/25/count-stopkey-operation-the-where-rownum/" rel="nofollow">http://blog.tanelpoder.com/2010/10/25/count-stopkey-operation-the-where-rownum/</a></p>
<p>Not that this is relevant to everyday operations, but I discovered this when moving tens of billions of rows onto an Exadata cluster&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
