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: Query that fetch whether any record exist

Re: Query that fetch whether any record exist

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Mon, 10 Jan 2000 20:34:23 +0800
Message-ID: <3879D1CF.2861@yahoo.com>


mig wrote:
>
> does anyone knows if it helps to write
>
> where...
> if rownum < 2
>
> in the exists - sub-query?
> akarb_at_xinfo.dk
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> Remco Blaakmeer wrote in message <85b7pe$95k$1_at_rd1936.quicknet.nl>...
> >In article <85ad31$jeh$1_at_news.netvision.net.il>,
> > "Maoz Mussel" <maoz_at_mindcti.com> writes:
> >> What is the fastest method to check whether ANY record satesfy the
> >> WHERE clause? For example, the following query:
> >> SELECT COUNT (*) FROM tableX
> >> WHERE ...
> >> May require full table scan in order to return number of records with the
> >> specified criteria. Same with any MIN function usage, while all I want is
> >> a boolean value specifying whether any record exist, i.e. one that will
> >> stop execution once the first record is found.
> >
> >SELECT 'yes, a record satisfies the WHERE clause'
> >FROM dual
> >WHERE EXISTS ( SELECT 'x' FROM tablea WHERE ... )
> >
> >The EXISTS clause will return TRUE at the first row returned from the
> >subquery. No more than one row will be fetched from the subquery.
> >
> >Remco
> >--
> >rd1936: 12:55am up 1 day, 5:34, 8 users, load average: 2.54, 2.33, 2.33

No - oracle will stop as soon as it finds the first record anyway..

HTH
--



Connor McDonald
"These views mine, no-one elses etc etc" connor_mcdonald_at_yahoo.com

"Some days you're the pigeon, and some days you're the statue." Received on Mon Jan 10 2000 - 06:34:23 CST

Original text of this message

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