Re: [GENERAL] IN vs EXISTS

2008-06-12 Thread Jeff Davis
On Sat, 2008-06-07 at 08:59 -0500, Adam Rich wrote: > what's faster on one dbms my be different than another. I've found > that postgresql is usually slower than other databases for IN () > queries, but handles EXISTS and inner joins (a third way of writing > your queries above) quite quickly. D

Re: [GENERAL] IN vs EXISTS

2008-06-12 Thread askel
Tom, I'm using 8.3.1. I did run EXPLAIN but have never familiarized myself with how to read/use it beside simple comparing cost estimation and whether there is any seq scan that can benefit from creating index. Thanks for replying On Jun 7, 11:19 am, [EMAIL PROTECTED] (Tom Lane) wrote: > askel <

Re: [GENERAL] IN vs EXISTS

2008-06-07 Thread Tom Lane
askel <[EMAIL PROTECTED]> writes: > Performance is at least few times better when EXISTS is used. It really shouldn't be. PG knows more possible plans for IN than EXISTS, so IN should pretty much always be equal or better ... unless the planner is making the wrong choice. I speculate that you ha

Re: [GENERAL] IN vs EXISTS

2008-06-07 Thread Adam Rich
> -Original Message- > > Hi all, > > I have been using IN clause almost exclusively until recently I tried > to use EXISTS and gained significant performance increase without > changing/creating any indexes: > > SELECT ... FROM a WHERE a.ref IN (SELECT b.id WHERE ...) > > vs > > SELECT

[GENERAL] IN vs EXISTS

2008-06-07 Thread askel
Hi all, I have been using IN clause almost exclusively until recently I tried to use EXISTS and gained significant performance increase without changing/creating any indexes: SELECT ... FROM a WHERE a.ref IN (SELECT b.id WHERE ...) vs SELECT ... FROM a WHERE EXISTS (SELECT 1 FROM b WHERE a.ref=