Re: Too slow - Mailing list pgsql-admin

From Tom Lane
Subject Re: Too slow
Date
Msg-id 11070.1111518881@sss.pgh.pa.us
Whole thread Raw
In response to Re: Too slow  ("Chris Hoover" <revoohc@sermonaudio.com>)
List pgsql-admin
"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

pgsql-admin by date:

Previous
From: "Chris Hoover"
Date:
Subject: PostgreSQL, INC. Support
Next
From: "ESPARZA JUAREZ EDUARDO"
Date:
Subject: Re: testing pgpool