Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: What to Count - WAS Re: Newbie ? - Howto find nbr records in a table

Re: What to Count - WAS Re: Newbie ? - Howto find nbr records in a table

From: Alan D. Mills <alanmNOSPAM_at_uk.europe.mcd.mot.com>
Date: Thu, 8 Oct 1998 16:44:24 +0100
Message-ID: <6vimjg$bcv$1@schbbs.mot.com>


I like this idea. If my primary key is a compound key (i.e. more than one column) should I just choose any one or aggregate (concatenate) them to a single value.

I'm not sure this idea will always work though as I find that when counting it's usually grouping by some combination which you can;t all get fromt he same index so you're back to hitting the table again.

From the rest of your answer though, it sounds like COUNT(*) is quicker than COUNT(9). In the former, no work at all is done, in the latter the expression '9' must be evaulated. Have I got this right?

--
Alan D. Mills

martinj (replace this with @) xs4all.nl wrote in message <361bdb16.1049308_at_news.xs4all.nl>...
>Hi,
>
>It does. The optimizer will recognize the '*' and react to it by NOT
>retrieving all data records. But, count(primary_key_field) will be
>even better, because that will only access the index. No data from the
>table has to be retrieved. So use count(pk-field) whenever you can.
>---------------------------------------------------------------------------


Received on Thu Oct 08 1998 - 10:44:24 CDT

Original text of this message

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