Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Age old question.. count(*), count(id) or count(1) faster ?
Hi,
select count(1) is faster. But because the Oracle optimizer knows this, it rewrites the query for you... So you won't see any difference when you look at the plan.
In older versions this rewrite would not take place.
I don't like to rely on the optimizer (since it can change it's mind), so I tend to use count(1).
Just my 2 cents,
Jef
EnderW wrote:
> Hi,
> No flames.. Have a quick question. I thought this matter be settled
> but it came up again. Is select count(*) from table faster than select
> count(id) from table or select count(1) from table faster ? I think all
> should be equal. ( id is an indexed column by itself in table). I did
> an explain plan and it came up same for those cases. Or is it not ? am
> I missing something ? Thnkx in adv.
>
> --
> Ender Wiggin
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Mon Jun 19 2000 - 00:00:00 CDT