Re: optimizing select ... not in (select ...) - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: optimizing select ... not in (select ...)
Date
Msg-id 200108131559.f7DFxmS19276@candle.pha.pa.us
Whole thread Raw
In response to optimizing select ... not in (select ...)  (Laurent Martelli <laurent@aopsys.com>)
List pgsql-sql
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
fromKeywords);
 
> 
> 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,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: Tomas Berndtsson
Date:
Subject: Re: optimizing select ... not in (select ...)
Next
From: Laurent Martelli
Date:
Subject: Re: optimizing select ... not in (select ...)