Re: How to find entries missing in 2nd table?

From: "Nate Teller" <nate(dot)teller(at)mindspring(dot)com>
To: "Aaron Bono" <postgresql(at)aranya(dot)com>, "Exner, Peter" <Exner(at)his(dot)de>
Cc: "Richard Broersma Jr" <rabroersma(at)yahoo(dot)com>, "SQL Postgresql List" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to find entries missing in 2nd table?
Date: 2006-07-17 01:09:48
Message-ID: JOEPKPKCCCBGEIEIKIIPCEHCDAAA.nate.teller@mindspring.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have received good performance with the following:

select c.controller
from control c
left outer join datapack d on d.controller_id = c.controller_id
where d.controller_id is null

Nate Teller

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of Aaron Bono
Sent: Thursday, July 13, 2006 11:46 AM
To: Exner, Peter
Cc: Richard Broersma Jr; SQL Postgresql List
Subject: Re: [SQL] How to find entries missing in 2nd table?

On 7/12/06, Exner, Peter < Exner(at)his(dot)de <mailto:Exner(at)his(dot)de> > wrote:
Hi,

what about

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?

==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
==================================================================

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message John Tregea 2006-07-17 01:11:12 Storing encrypted data?
Previous Message Tom Lane 2006-07-16 02:22:32 Re: Regular Expression in SQL