From: Michael Fuhr <mike@fuhr.org>
To: Karim Nassar <karim.nassar@acm.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: Two queries are better than one?
Date: Thu, 28 Jul 2005 19:53:22 -0600
Message-ID: <20050729015322.GA25003@winnie.fuhr.org> (raw)
In-Reply-To: <1122591866.11860.11.camel@localhost.localdomain>
References: <1122591866.11860.11.camel@localhost.localdomain>
On Thu, Jul 28, 2005 at 04:04:25PM -0700, Karim Nassar wrote:
> I ran into a situation today maintaining someone else's code where the
> sum time running 2 queries seems to be faster than 1. The original code
> was split into two queries. I thought about joining them, but
> considering the intelligence of my predecessor, I wanted to test it.
>
> The question is, which technique is really faster? Is there some hidden
> setup cost I don't see with explain analyze?
To see which technique will be faster in your application, time the
application code. The queries you show are taking fractions of a
millisecond; the communications overhead of executing two queries
might make that technique significantly slower than just the server
execution time that EXPLAIN ANALYZE shows.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mike@fuhr.org, karim.nassar@acm.org
Subject: Re: Two queries are better than one?
In-Reply-To: <20050729015322.GA25003@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox