Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: The use of COUNT(*)
Not totally sure, but count has to search all the rows that would be
retrieved (filtered by your where clause, of course) and sum them up
whereas %FOUND probably stops at the first row found and says "Good
enough!" and doesn't bother with the rest of them. Educated guess, though
- I'm not a really good PL/SQL -type.
--
Matt Brennan
SQL*Tools Specialist
GERS Retail Systems
9725-C Scranton Road
San Diego, California 92121
1-800-854-2263
mbrennan_at_gers.com
(Original email address is spam-blocked.)
Lai King Leung <LaiKing_at_syslogic.com> wrote in article
<01bdabde$e3f537f0$92cc0bc3_at_carrera_09>...
> Could anyone tell me about the use of COUNT(*)? I currently use the
> comamnd
>
> SELECT COUNT(*) INTO v_count FROM tbl_data WHERE ... in my PL/SQL program
> unit, to determine whether there are any records to be processed.
>
> In some cases I use the command
> SELECT COUNT(*) INTO v_count FROM tbl_tmpdata to determine if there is
any
> data in the table.
>
> I've been told that it is very inefficient to use COUNT(*) and that I
> should declare a CURSOR and look at the %FOUND attribute instead ??
>
> I would appreciate any suggestions on the use of COUNT(*) especially when
> it should be used, and when it should be avoided at all cost.
>
> Thank-you in adavnce
> Regards
> Lai King
Received on Fri Jul 10 1998 - 11:01:22 CDT
![]() |
![]() |