Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: What to Count - WAS Re: Newbie ? - Howto find nbr records in a table
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.
>---------------------------------------------------------------------------