"Chris Hoover" <revoohc@sermonaudio.com> writes:
> The "not in (subselect)" is very slow in postgresql.
It's OK as long as the subselect result is small enough to hash, but
with 5500000 rows that's not going to happen :-(.
Another issue is that if there are any NULLs in the subselect then you
will probably not like the results. They are correct per spec but not
very intuitive.
Personally I'd try ye olde outer join trick:
select partes.*
from partes left join sujetos on (identificacion = cedula)
where cedula is null;
A merge join on this would likely be the most effective solution.
regards, tom lane