pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Broersma Jr <rabroersma@yahoo.com>
To: Aaron Bono <postgresql@aranya.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 09:33:52 -0700 (PDT)
Message-ID: <20060713163352.65195.qmail@web31801.mail.mud.yahoo.com> (raw)
In-Reply-To: <bf05e51c0607130925u12635434v98d877a7f1eb449a@mail.gmail.com>

> > > > 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);


Well in this case,  the group by or distinct is simple not needed for the query to preform
correctly.  The additional group by clause in the second query could cause it to preform
additional processing which "may" cause it to preform slower.

Regards,

Richard Broersma Jr.



view thread (13+ messages)  latest in thread

Message-ID: <20060713163352.65195.qmail@web31801.mail.mud.yahoo.com>
Permalink:  ../20060713163352.65195.qmail@web31801.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/20060713163352.65195.qmail@web31801.mail.mud.yahoo.com

 · 

reply

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: rabroersma@yahoo.com, postgresql@aranya.com, Exner@his.de
  Subject: Re: How to find entries missing in 2nd table?
  In-Reply-To: <20060713163352.65195.qmail@web31801.mail.mud.yahoo.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