[nycphp-talk] more queries, or bigger in-memory data structure ?
David Mintz
dmintz at panix.com
Thu Sep 18 15:57:37 EDT 2003
Thanks Adam.
I had a feeling the answer would be something like that. I don't know
techniques for measuring memory usage/db access tradeoffs so I don't know
objectively.... I believe the answer to the snarky answers is, no there's
not such a big load on our (one) server and I can surely get away with
either approach, but I'd like to do it "right". I think I will stick with
more PHP/less MySQL.
BTW -- once I had a similar scenario with a Perl/CGI/DBI script and I went
with the big data structure approach, and the thing was so astonishingly
slow (on a shared server) that I know something had to be hideously wrong.
On Thu, 18 Sep 2003, Adam Maccabee Trachtenberg wrote:
> 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
More information about the talk
mailing list