[nycphp-talk] mySQL optimization question.
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Tue May 27 13:09:46 EDT 2003
On Tue, 27 May 2003, Malcolm, Gary wrote:
> 1. don't use count(*) because mysql will pull all fields for every record...
> use $result = mysql_query("SELECT count(col_name) FROM table_name");
>
> 2. db's are optimized for this query so their return is like greased
> lightening :)
>
> 3. let the db do the work!
4. You want to send as little information between the database and PHP
as possible because it's faster. Having mySQL do the count means
you're sending a number instead of a whole bunch of text. (This
isn't such a big deal here, since the amount of text is small.)
-adam
--
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!
More information about the talk
mailing list