Magnus Naeslund(f) wrote:
> Hello, i've got this query that's really slow...
> Figure this:
>
> testdb=> select now() ; select gid from bs where gid not in ( select x
> from z2test ); select now();
"IN (subselect)" is notoriously slow (in fact it is an FAQ). Can you rewrite
this as:
select b.gid from bs b where not exists (select 1 from z2test z where z.x =
b.gid);
or possibly:
select b.gid from bs b left join z2test z on z.x = b.gid where z.x IS NULL;
HTH,
Joe