[PHP] Question on response time, SQL vs. PHP
I'm trying to do a count(*) in SQL. Would it be faster to do a or b below? a: just do a simple query, and use mysql_num_rows() to return the row count; or b: do the count(*) and use mysql_fetch_row() to return the result. I guess it would have to do more with SQL response time (is it faster to grab the count and then the row, or all rows in question and then do a count in PHP).
RE: [PHP] Question on response time, SQL vs. PHP
It is faster to do a count(*) -Original Message- From: Liam Gibbs [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2003 1:31 PM To: php list Subject: [PHP] Question on response time, SQL vs. PHP I'm trying to do a count(*) in SQL. Would it be faster to do a or b below? a: just do a simple query, and use mysql_num_rows() to return the row count; or b: do the count(*) and use mysql_fetch_row() to return the result. I guess it would have to do more with SQL response time (is it faster to grab the count and then the row, or all rows in question and then do a count in PHP). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question on response time, SQL vs. PHP
It's faster to use count(*), because it just has to fetch a count of the rows (but not the rows themselves). If you're retrieving the rows anyway, you should use mysql_num_rows, Liam Gibbs wrote: I'm trying to do a count(*) in SQL. Would it be faster to do a or b below? a: just do a simple query, and use mysql_num_rows() to return the row count; or b: do the count(*) and use mysql_fetch_row() to return the result. I guess it would have to do more with SQL response time (is it faster to grab the count and then the row, or all rows in question and then do a count in PHP). -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php