Re: subqueries vs. separate queries

From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: subqueries vs. separate queries
Date: 2004-01-29 22:35:10
Message-ID: 60ad462xk1.fsf@dev6.int.libertyrms.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

cool_screen_name90001(at)yahoo(dot)com (CSN) writes:
> Is there much difference between using subqueries and separating out
> them into separate queries?

Yes. No. Maybe.

What kind of difference are you thinking about?

If you join queries together, you wind up with fewer queries, and your
outside code that manipulates the results will likely have less work
to do. There are certainly notions of "efficiency" and "simplicity"
that can out of that.

By the same token, those fewer queries are sure to be a bit more
complex, may be more difficult to write and understand, and may poke
at "edges" of the query optimizer such that they _may_, if you are
very unlucky, run unexpectedly slowly.

It is quite possible for the simplifications of your application to
outweigh the _possible_ costs...
--
output = ("cbbrowne" "@" "ntlug.org")
http://cbbrowne.com/info/linux.html
Would-be National Mottos:
USA: "We don't care where you come from. We can't find our *own*
country on a map..."

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Manuel Tejada 2004-01-30 01:50:47 Re: I can't upgrade to PostgreSQL 7.4 in RedHat 9.0
Previous Message Guy Fraser 2004-01-29 22:14:13 Re: subqueries vs. separate queries