It seems that count(*) pulls all the data from the row then performs a count 
increment whereas count(did) only pulls the 'did' column.

I wonder if count(did) is the same speed as count(1) or if it will depend on 
how much/what type of data is in 'did'.


I also wonder why count() takes a parameter.  Isn't it always going to count 
+1 for the row?   I'll have to look that up sometime.

-TG

----- Original Message -----
From: "Nathan Nobbe" <[EMAIL PROTECTED]>
To: "Andrew Ballard" <[EMAIL PROTECTED]>
Cc: "PHP General list" <php-general@lists.php.net>
Date: Wed, 19 Mar 2008 10:35:16 -0400
Subject: Re: [PHP] Fastest way to get table records' number

> On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard <[EMAIL PROTECTED]> wrote:
> 
> > That works; I'm just wondering why you went with a count on an 'ID' column
> > rather than COUNT(*).
> 
> 
> ouch, it looks like im horribly wrong :O
> mysql> select count(*) from table;
> +----------+
> | count(*) |
> +----------+
> |   361724 |
> +----------+
> 1 row in set (0.90 sec)
> 
> mysql> select count(id) from table;
> +------------+
> | count(did) |
> +------------+
> |     361724 |
> +------------+
> 1 row in set (4.56 sec)
> 
> -nathan
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to