Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: fastest way to determine if 0 or more records are present in table?
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
![]() |
![]() |