Re: optimizing queries using IN and EXISTS

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Nick Hofstede <Nick(dot)Hofstede(at)inventivegroup(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: optimizing queries using IN and EXISTS
Date: 2012-07-18 18:40:28
Message-ID: CAEYLb_XxqdVKH9L1NBjk6yxhdKi-QMUrHi7KC14KbdS4cwuzDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 18 July 2012 17:10, Nick Hofstede <Nick(dot)Hofstede(at)inventivegroup(dot)com> wrote:
> Hi,
>
> I'm surprised at the difference in speed/execution plan between two logically equivalent queries, one using IN, the other using EXISTS. (At least I think they are logically equivalent)

They are not logically equivalent.

http://www.postgresql.org/docs/current/static/functions-subquery.html

See the notes about NULL under IN.

--
Peter Geoghegan http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2012-07-18 19:32:46 Re: Array fundamentals
Previous Message Nick Hofstede 2012-07-18 16:10:30 optimizing queries using IN and EXISTS