From: | Sameer Kumar <sameer(dot)kumar(at)ashnik(dot)com> |
---|---|
To: | Steve Crawford <scrawford(at)pinpointresearch(dot)com> |
Cc: | PostgreSQL General Discussion Forum <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: NOT IN and NOT EXIST |
Date: | 2014-07-04 04:12:05 |
Message-ID: | CADp-Sm5AxY3EzDDk2XzNO8gcu8GEbOzv3YzzS0KLPEzzc1gBNA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Jul 3, 2014 at 11:52 PM, Steve Crawford <
scrawford(at)pinpointresearch(dot)com> wrote:
> You can easily test this for yourself using explain.
I tried it out.
NOT EXISTS translates to HASH ANTI JOIN and NOT IN translates to NOT
(HASHED) operation.
Given that the columns used in NOT IN clause (for outer as well as inner)
are NOT NULL, should not it translate a NOT IN plan similar to NOT EXISTS
plan?
Also note that depending on the version of PostgreSQL and the nature of
> your data it could be preferable to use WHERE IN... or to use EXISTS.
> Fortunately as the planner has been imbued with ever increasing smarts, the
> need to test and choose between the two seems to have diminished.
Postgres already does that for IN and EXISTS. Both would try to use HASH.
But does not seem to be the case with NOT IN and NOT EXISTS.
Best Regards,
*Sameer Kumar | Database Consultant*
*ASHNIK PTE. LTD.*
101 Cecil Street, #11-11 Tong Eng Building, Singapore 069533
M: *+65 8110 0350* T: +65 6438 3504 | www.ashnik.com
*[image: icons]*
[image: Email patch] <http://www.ashnik.com/>
This email may contain confidential, privileged or copyright material and
is solely for the use of the intended recipient(s).
From | Date | Subject | |
---|---|---|---|
Next Message | David Wall | 2014-07-04 04:26:18 | Re: pg_dump slower than pg_restore |
Previous Message | Bosco Rama | 2014-07-04 01:26:16 | Re: pg_dump slower than pg_restore |