Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Checking if more than 0 rows exist.

Re: Checking if more than 0 rows exist.

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Wed, 11 May 2005 07:51:34 -0700
Message-ID: <1115822843.449556@yasure>


Frank van Bortel wrote:

> DA Morgan wrote:
>
>

>>>Where's the cursor/open/fetch?
>>
>>
>>Ask Oracle.  ;-)
>>
>>What you see is the result of AUTOTRACE TRACEONLY in 10.1.0.4.
>>I performed no editing.
>>

>
>
> No, Daniel, I'm asking you, as you dismiss a cursor solution
> as fit for Oracle Version over 5 year old, and useless in any
> other version.
>
> You compare rownum=1, combined with an index to an exists.
> Reality check:
>
> SQL> select 1 from dual where exists (select empno from scott.emp);
>
> 1
> ----------
> 1
>
> Elapsed: 00:00:00.29
>
> Execution Plan
> ----------------------------------------------------------
> 0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=3 Card=1)
> 1 0 FILTER
> 2 1 FAST DUAL (Cost=2 Card=1)
> 3 1 INDEX (FULL SCAN) OF 'PK_EMP' (INDEX (UNIQUE)) (Cost=1 C
> ard=14)
>
>
>
>
>
> Statistics
> ----------------------------------------------------------
> 122 recursive calls
> 0 db block gets
> 27 consistent gets
> 1 physical reads
> 0 redo size
> 386 bytes sent via SQL*Net to client
> 512 bytes received via SQL*Net from client
> 2 SQL*Net roundtrips to/from client
> 0 sorts (memory)
> 0 sorts (disk)
> 1 rows processed
>
>
> declare
> cursor c_emp is select empno from scott.emp;
> dummy c_emp%rowtype;
> begin
> open c_emp;
> fetch c_emp into dummy;
> if c_emp%found then
> null;
> end if;
> close c_emp;
> end;
> /
> PL/SQL procedure successfully completed.
>
> Elapsed: 00:00:00.04

What is the relationship between what you've done and anything in the original post? They do completely different things.

Selecting 1 row out of a table with 14 rows is not going to give you anything meaningful no matter what you are testing.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Wed May 11 2005 - 09:51:34 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US