stefan(at)konink(dot)de writes:
> The following is relatively fast:
> bag-2012-aug=# explain select count(*) from (select kvk from kvk_normal
> except select kvk from bag_kvk) as x;
> The 'normal' case basically doesn't finish:
> bag-2012-aug=# explain select count(*) from (select kvk_normal.kvk from
> kvk_normal where kvk_normal.kvk not in (select bag_kvk.kvk from bag_kvk)) as
> x;
NOT IN is difficult to optimize, as well as hard to use, because of its
rather bizarre behavior for nulls. You might consider using NOT EXISTS
instead.
regards, tom lane