Re: Fastest way to get table records' number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

did you try mysql_num_rows ?

--- Andrew Ballard <aballard@xxxxxxxxx> wrote:

> On Wed, Mar 19, 2008 at 1:04 PM, TG
> <tg-php@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> >  It seems that count(*) pulls all the data from
> the row then performs a count
> >  increment whereas count(did) only pulls the 'did'
> column.
> 
> Again, I don't believe COUNT(*) pulls any data. If
> there is a row, it
> simply counts it. The row could be full of NULLS (if
> allowed by your
> schema - yikes) and it will still be counted. I'd
> guess that COUNT(1)
> does the same thing. COUNT(did) does only examine
> the `did` column,
> but NULL values are excluded from the count.
> 
> >  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.
> 
> It takes a parameter because it depends on what you
> want to count.
> COUNT(*) will return the number of rows matching the
> WHERE clause.
> COUNT(`column_name`) will return the number of
> non-NULL values in the
> column `column_name`. You could have a million rows
> in the table, but
> if every row has NULL in `column_name`, the COUNT()
> will return 0.
> There is also COUNT(DISTINCT `column_name`), which
> counts the number
> of distinct, non-NULL values in the column.
> 
> Andrew
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux