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: fastest way to determine if 0 or more records are present in table?

Re: fastest way to determine if 0 or more records are present in table?

From: FC <flavio_at_tin.it>
Date: 19 Feb 2004 05:36:05 -0800
Message-ID: <2bd78ddf.0402190536.53e702c2@posting.google.com>


Chuck <chuckh_nospam_at_softhome.net> wrote in message news:<Xns94937D64E2FFchuckhsofthomenet_at_130.133.1.4>...
>
> ...
>
> But you probably don't want to query the entire table of there are
> millions of rows. I'd use a simple query like this...
>
> select count(*) from mytable where rownum < 2;
>
> Returns 0 if no rows exist, or 1 if 1 or more rows exit.

I agree, after comparing the output of autotrace, the simple query above guarantees the quickest answer, even when you specify further conditions in the where clause.

I took for granted what was stated 4 years ago, but it doesn't seem to hold any more.
May be the optimizer of versions prior to 8.1.7 was not that smart.

Bye,
Flavio Received on Thu Feb 19 2004 - 07:36:05 CST

Original text of this message

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