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: The use of COUNT(*)

Re: The use of COUNT(*)

From: doid <doid_at_usa.net>
Date: Fri, 10 Jul 1998 18:04:00 GMT
Message-ID: <35A658AC.861A5E01@usa.net>


Been there:)

  1. count(*) won't count nulls. this can screw up your logic sometimes...anyway, it's much more efficent to count( <some indexed column> ) or count(1)
  2. you don't really want to count every row if you only care about finding the first occurrence of a condition
  3. i like: BEGIN
SELECT 1
INTO temp
FROM mytab
WHERE ROWNUM <=1
AND < condition >;

found := TRUE;

EXCEPTION
    WHEN NO_DATA_FOUND THEN
        found := FALSE;
END; 4) alternatively

found := FALSE;
FOR csr IN ( <query> ) LOOP

    found := TRUE;
    EXIT;
END LOOP; It's probably more a matter of style than anything. I think they perform similarly. You should confirm this yourself with TKPROF, or whichever tool you like.

Hope this helped,

doid

Lai King Leung wrote:

> Could anyone tell me about the use of COUNT(*)?
Received on Fri Jul 10 1998 - 13:04:00 CDT

Original text of this message

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