Addressed to: Javier Muniz <[EMAIL PROTECTED]>
Joe Sheble (Wizaerd) [mailto:[EMAIL PROTECTED]]
[EMAIL PROTECTED]
** Reply to note from Javier Muniz <[EMAIL PROTECTED]> Fri, 16 Feb 2001
10:14:29 -0800
>
> You should use fieldnames in your selects... I'd imagine count(*)
> would be slower just as select * is slower.
I agree, SELECT should always specify only the fields you want returned, but
COUNT(*) is an optimization. From the MySQL manual:
http://www.mysql.com/doc/G/r/Group_by_functions.html
COUNT(*) is somewhat different in that it returns a count of the number
of rows retrieved, whether or not they contain NULL values. COUNT(*) is
optimized to return very quickly if the SELECT retrieves from one table,
no other columns are retrieved, and there is no WHERE clause.
For example SELECT COUNT(*) FROM TableName will not even look at the table, it
can get the number of entries from the index, and return it almost instantly. If
you used SELECT COUNT(SomeField) FROM TableName MySQL would have to scan the
table to make sure none of the SomeField values were NULL, which would not be
included in the count. This can take quite a bit more time.
Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]