[nycphp-talk] more queries, or bigger in-memory data structure ?
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Thu Sep 18 15:43:13 EDT 2003
On Thu, 18 Sep 2003, David Mintz wrote:
> My question is, would it be more efficient to do the first query first,
> and as I loop through the result, query the related tables, resulting in
> maybe 60 queries per page access? Or do it with a lot fewer database
> calls, but suck up more memory?
I believe the snarky answer is: "It depends. Do you have more memory
on your Web server boxes or excess processor cycles on your database
machines?"
The second snarky answer is: "Does it even matter? Are your machines
under such load that this comparison is meaningful? If not, code
whatever is most maintainable and document that the other solution may
be necessary under duress." (Alt Answer: Is one significantly faster?)
Finally, my answer is that 60 database calls seems like a lot. I would
probably do fewer calls and more in PHP. Again, I would need to know
the memory footprint and the speed tradeoffs.
-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