Re: count (1) and count (*)

From: Daniel Roy <danielroy10junk_at_hotmail.com>
Date: 31 Oct 2003 12:14:30 -0800
Message-ID: <3722db.0310311214.261380bf_at_posting.google.com>


Thanx Frank for the correction. I now remember that it was in a Google thread that I saw this. But as Tom Kyte mentioned on the thread you quote, it used to be that select count(*) and select count(1) were treated differently, in versions 7 and lower. That's probably why I saw that comment on an old Google thread about how differently they're treated.

Daniel

> Daniel Roy wrote:
> > I read somewhere (asktom?) that "select count(1) from table" is
> > internally rewritten as "select count(*) from (select 1 from table)",
> > and therefore just adds some overhead.
> >
> > Daniel
> >
> > gelangov_at_hotmail.com (Geetha) wrote in message news:<4b40e20a.0310290724.13e86079_at_posting.google.com>...
> >
> >>I searched in the Oracle documents what count (1) meant and I could
> >>not find an answer. Can some one explain what Oracle does internally
> >>when use count (1) VS count (*). Thank you very much in advance! We
> >>use Oracle 9i.
>
> NO!
> Actually Tom wrote:
> "Prove it, give me that test case. You are wrong.
> COUNT(*) and COUNT(1) are the *same* -- the same -- the same -- no
> different, the same.
> count(1) is internally optimized to count(*) "
>
> And he posted the explain plans for count(*) and count(1).
Received on Fri Oct 31 2003 - 21:14:30 CET

Original text of this message