Re: What's faster? MySQL Queries or PHP Loops?
| From: | Chris Shiflett | Date: | Wed, 08 Sep 2004 15:41:14 +0000 |
| Subject: | Re: What's faster? MySQL Queries or PHP Loops? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196142@lists.php.net to get a copy of this message | ||
--- Robb Kerr <rkerr.news@digitaliguana.com> wrote:
> Here's the question...
>
> I can either A) in the header or my page, generate a recordset
> of all of the records in the related table and then loop through
> the recordset creating an array of the fields I need and then
> later pull from it in the repeat region... or B) take the six
> lines of code Dreamweaver generates to create a recordset and
> move them into the repeat region itself.
I don't completely understand your terminology, but it's always faster to
get all of your data with a single query rather than a query per loop. Of
course, the difference is that it also requires more memory. In general,
if you have the memory, use it. It will always be faster.
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security - O'Reilly
Coming Fall 2004
HTTP Developer's Handbook - Sams
http://httphandbook.org/
PHP Community Site
http://phpcommunity.org/