NOT IN and NOT EXIST - Mailing list pgsql-general

From Sameer Kumar
Subject NOT IN and NOT EXIST
Date
Msg-id CADp-Sm5O-n+upp-B+6SUq-wT6EeEBrjoR_roPkOp7D8Rnk2K5w@mail.gmail.com
Whole thread Raw
Responses Re: NOT IN and NOT EXIST  (Steve Crawford <scrawford@pinpointresearch.com>)
List pgsql-general

Hi,

Postgres optimizer automatically tries to convert an IN clause to Hash Join (something similar to EXISTS equivalent of that query).

Does a similar translation happen for NOT IN as well? Given that the column used is NOT NUL.

Select * from emp where deptid not in (select deptid from dept where deptLocation='New York');

Will this above statement be automatically converted to a plan which would match below statement?

Select * from emp where not exists (select 1 from dept where deptLocation='New York' and dept.deptid=emp.deptid);

Regards
Sameer

PS: Sent from my Mobile device. Pls ignore typo n abb

pgsql-general by date:

Previous
From: Dave Cramer
Date:
Subject: Re: postgresql server version & JDBC driver version
Next
From: Steve Crawford
Date:
Subject: Re: NOT IN and NOT EXIST