Re: Difference between count(1) and count(*)

  • From: Tanel Põder <tanel.poder.003@xxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 8 Jul 2004 11:38:01 +0300

I've actually seen an "expert" optimizing the count() statement, by using
count(null) "since null means nothing and thus is the fastest" :)

But check this:

SQL> select count(*) from dual;

  COUNT(*)
----------
         1

SQL> select count(null) from dual;

COUNT(NULL)
-----------
          0

Tanel.

----- Original Message ----- 
From: "Jeremiah Wilton" <jwilton@xxxxxxxxxxxxx>
To: <oracle-l@xxxxxxxxxxxxx>
Sent: Thursday, July 08, 2004 9:31 AM
Subject: Re: Difference between count(1) and count(*)


> > On Thu, 8 Jul 2004 11:27:28 +0530 oracle-l@xxxxxxxxxxxxx wrote:
> > > Can you let me know the difference between count(*) and count(1) ?
> >
> > count(1) is supposed to be more efficient and faster.
>
> Oh boy, here we go.
>
> --
> Jeremiah Wilton
> http://www.speakeasy.net/~jwilton
> ----------------------------------------------------------------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> ----------------------------------------------------------------
> To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
> put 'unsubscribe' in the subject line.
> --
> Archives are at //www.freelists.org/archives/oracle-l/
> FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
> -----------------------------------------------------------------
>


----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: