PostgreSQL and NOT IN
PostgreSQL treats LEFT JOIN
and NOT EXISTS
equally, using same execution plan for both of them (namely a Hash Anti Join
for the example above).
As for NOT IN
, which is semantically different since its logic is trivalent and it can return NULL
, PostgreSQL tries to take this into account and limits itself to using a filter against a subplan
(a hashed subplan
for a hashable resultset like in example above).