Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7DDWlP58065 for ; Mon, 13 Aug 2001 09:32:47 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f7DDHP008621 for pgsql-sql@postgresql.org; Mon, 13 Aug 2001 09:17:25 -0400 (EDT) (envelope-from news) From: Laurent Martelli X-Newsgroups: comp.databases.postgresql.sql Subject: optimizing select ... not in (select ...) Date: 13 Aug 2001 15:17:23 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 10 Message-ID: <87bslkayl8.fsf@lolo.aopsys> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: scrappy@hub.org User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 To: pgsql-sql@postgresql.org X-Archive-Number: 200108/165 X-Sequence-Number: 4386 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/