Received: from candle.pha.pa.us (candle.navpoint.com [162.33.245.46]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7DFxtP08079 for ; Mon, 13 Aug 2001 11:59:55 -0400 (EDT) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.10.1/8.10.1) id f7DFxmS19276; Mon, 13 Aug 2001 11:59:48 -0400 (EDT) From: Bruce Momjian Message-Id: <200108131559.f7DFxmS19276@candle.pha.pa.us> Subject: Re: optimizing select ... not in (select ...) In-Reply-To: <87bslkayl8.fsf@lolo.aopsys> "from Laurent Martelli at Aug 13, 2001 03:17:23 pm" To: Laurent Martelli Date: Mon, 13 Aug 2001 11:59:48 -0400 (EDT) CC: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL90 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200108/169 X-Sequence-Number: 4391 Can it be redone using NOT EXISTS? > I have this query : > > select distinct on (Pictures.PictureID) * from Pictures where Pictures.PictureID not in (select distinct PictureID from Keywords); > > and I find it a bit slow. Does anybody have suggestions to run this > faster ? (I have indexes on PictureID on both Pictures and Keywords) > > -- > Laurent Martelli > laurent@aopsys.com http://www.bearteam.org/~laurent/ > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026