Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Select Statement
Are you sure about this? Examine the following extremely simple test
case...
/**********************************************************************
SQL> create table t0421(c number, d number);
Table created.
--load 100000 rows
SQL> begin
2 for i in 1..100000 loop
3 insert into t0421 values(mod(i,1000),i);
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> set autotrace traceonly
--get those rows where d=1 and it is the first rownum that matches the
criteria...
SQL> select d from t0421 where d=1 and rownum<2;
Execution Plan
|
Predicate Information (identified by operation id):
1 - filter(ROWNUM<2)
2 - filter("D"=1)
--get only those rows that match the criteria, without the rownum
pseudo column
SQL> select d from t0421 where d=1;
Execution Plan
Predicate Information (identified by operation id):
1 - filter("D"=1)
Note
--filter only those rows with the rownum of 1
SQL> select d from t0421 where rownum<2;
Execution Plan
|
Predicate Information (identified by operation id):
1 - filter(ROWNUM<2)
Note
**********************************************************************/
The cardinality (and I/O, which I don't show), although reflecting a full table scan, do very little I/O when I filter on the column, even without an index. When I use only the rownum, the cardinality and I/O increases.
Can you post the full trace?
Regards,
Steve Received on Fri Apr 21 2006 - 10:12:26 CDT