Re: [SQL] optimizing select ... not in (select ...)

2001-08-13 Thread Bruce Momjian
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 o

Re: [SQL] optimizing select ... not in (select ...)

2001-08-13 Thread Tomas Berndtsson
Laurent Martelli <[EMAIL PROTECTED]> writes: > 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

Re: [SQL] optimizing select ... not in (select ...)

2001-08-13 Thread Josh Berkus
Laurent, > 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) NOT IN

[SQL] optimizing select ... not in (select ...)

2001-08-13 Thread Laurent Martelli
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) -- L