From: Aaron Bono <postgresql@aranya.com>
To: Richard Broersma Jr <rabroersma@yahoo.com>
Cc: Exner, Peter <Exner@his.de>
Cc: SQL Postgresql List <pgsql-sql@postgresql.org>
Subject: Re: How to find entries missing in 2nd table?
Date: Thu, 13 Jul 2006 11:25:03 -0500
Message-ID: <bf05e51c0607130925u12635434v98d877a7f1eb449a@mail.gmail.com> (raw)
In-Reply-To: <20060713161651.39567.qmail@web31809.mail.mud.yahoo.com>
References: <bf05e51c0607130846ufdb8a31n5757f67361447c2b@mail.gmail.com>
<20060713161651.39567.qmail@web31809.mail.mud.yahoo.com>
On 7/13/06, Richard Broersma Jr <rabroersma@yahoo.com> wrote:
>
> > > SELECT controller_id FROM control
> > > WHERE controller_id NOT IN
> > > (SELECT DISTINCT controller_id FROM datapack);
> > The DISTINCT is not necessary. I have heard with Oracle that DISTINCT
> is a
> > huge performance problem. Is that true on PostgreSQL also?
>
> From my experience, it does not preform as well as the standard group by
> clause. I noticed a ~20%
> increase in query run times.
So in that case this would be better:
SELECT controller_id FROM control
WHERE controller_id NOT IN
(SELECT controller_id FROM datapack);
or
SELECT controller_id FROM control
WHERE controller_id NOT IN
(SELECT controller_id FROM datapack GROUP BY controller_id);
Guess you need to do some explain plans to see which would be best.
Good luck!
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
==================================================================
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-sql@postgresql.org
Cc: postgresql@aranya.com, rabroersma@yahoo.com, Exner@his.de
Subject: Re: How to find entries missing in 2nd table?
In-Reply-To: <bf05e51c0607130925u12635434v98d877a7f1eb449a@mail.gmail.com>
* 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