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
Hi,
>This raises a question for me. The use of COUNT(*) that is. A few years
>ago, in my early days of Oracle, a chap with more experience than I
>explained that he always used COUNT(9) as opposed to COUNT(*) when doing
>this sort of thing. Obviously, it makes absolutley no difference to the
>answer.
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.