X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5AAA29FB41A for ; Wed, 12 Jul 2006 15:13:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 84369-07 for ; Wed, 12 Jul 2006 15:13:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id E9F9E9FB440 for ; Wed, 12 Jul 2006 15:13:19 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Wed, 12 Jul 2006 18:13:18 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 12 Jul 2006 13:13:18 -0500 Subject: Re: How to find entries missing in 2nd table? From: Scott Marlowe To: "Exner, Peter" Cc: Richard Broersma Jr , SQL Postgresql List In-Reply-To: <507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de> References: <507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1152727998.14241.24.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 12 Jul 2006 13:13:18 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/193 X-Sequence-Number: 25767 On Wed, 2006-07-12 at 03:06, Exner, Peter wrote: > Hi, > > what about > > SELECT controller_id FROM control > WHERE controller_id NOT IN > (SELECT DISTINCT controller_id FROM datapack); That one works too, but it's generally not as fast as the left join / is null query on large tables. Give the two a try on a test set and you should see the speed difference.