OK. 200 iterations with a total difference of 2.42 seconds using almost 6
million records. That is a difference of 120 milliseconds per iteration.
That is a trivial difference. I consider count(*) more readable than
count(column) and more clearly indicates the purpose. Make code readable.
Machines can be easily upgraded to be faster if performance is an issue,
humans are not easily and cheaply upgraded.

Ray Thompson
Tau Beta Pi ( <http://www.tbp.org/> www.tbp.org)
The Engineering Honor Society
865-546-4578  

  _____  

From: Adam Haskell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 13, 2004 3:00 PM
To: SQL
Subject: Re: Faster count?

I just ran a test (200 itterations) on a table with 5,801,195 records.
The average for count(id) was: 98.804
The average for count(*) was: 101.22

If you look in QA they actualy run the same exact execution. count(*)
exectued on object ref_id_idx which is the colum I used in the
count(id). So atleast in my example count(id) and count(*) are the
same exact thing.

Adam

----- Original Message -----
From: Raster, Tim <[EMAIL PROTECTED]>
Date: Tue, 13 Jul 2004 13:31:48 -0500
Subject: RE: Faster count?
To: SQL <[EMAIL PROTECTED]>

Actually, I think count(*) is faster.  It is a special signal to the
server that it doesn't have to count field values, but rows, which saves
time having to evaluate rows.  Unlike select *, it does NOT mean all
fields... it means all rows.  So count(*) is faster.

-----Original Message-----
From: Adam Haskell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 13, 2004 13:28
To: SQL
Subject: Re: Faster count?

no...its slower. Always count an indexed column if possible.

----- Original Message -----
From: Michael Dinowitz <[EMAIL PROTECTED]>
Date: Tue, 13 Jul 2004 14:24:59 -0400
Subject: Faster count?
To: SQL <[EMAIL PROTECTED]>

Is count (*) faster than count(specific_field)?
Thanks
--
Michael Dinowitz
http://www.houseoffusion.com
For all your ColdFusion needs________________________________
________________________________________________________________

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to