NYCPHP Meetup

NYPHP.org

[nycphp-talk] more queries, or bigger in-memory data structure ?

Chris Shiflett shiflett at php.net
Thu Sep 18 17:05:03 EDT 2003


--- Analysis & Solutions <danielc at analysisandsolutions.com> wrote:
> With clever looping and comparisons, I bet you could get what
> you want with one query.

I might be misinterpreting his question, but I believe he was asking whether he
should, not whether he could.

As Adam mentioned, with one query, you place a lot of data in memory, which is
good if you can handle it and bad if you can't. With multiple queries, you
create more load on the database, it might be slower, etc.

Without having a good idea about the particular tradeoffs in someone's
situation, it is hard to suggest one way over the other. Personally, I try to
organize my data so well that my queries are as simple as possible (I'm not
joining multiple tables all the time), useful as possible (I can get exactly
the data I need from a simple query), and use up as little memory as possible
(the number of records returned are no more than I need). Given this, I almost
always limit my interactions with the database and do everything in PHP.

Hope that helps.

Chris



More information about the talk mailing list