Re: IN vs EXISTS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: askel <dummy666(at)mail(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: IN vs EXISTS
Date: 2008-06-07 15:19:10
Message-ID: 20156.1212851950@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

askel <dummy666(at)mail(dot)ru> 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 have
out-of-date statistics or some such. Have you compared EXPLAIN ANALYZE
output for the two cases? Which PG version are we talking about?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-06-07 15:24:34 Re: Extracting data from deprecated MONEY fields
Previous Message Scott Marlowe 2008-06-07 14:53:01 Re: temporarily deactivate an index