Re: BUG #7509: x NOT IN (select x from z) extremely slow in compare to select x from y except select x from z; - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #7509: x NOT IN (select x from z) extremely slow in compare to select x from y except select x from z;
Date
Msg-id 10470.1346253644@sss.pgh.pa.us
Whole thread Raw
In response to BUG #7509: x NOT IN (select x from z) extremely slow in compare to select x from y except select x from z;  (stefan@konink.de)
List pgsql-bugs
stefan@konink.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: hot standby lagging vs warm that is up-to-date
Next
From: Stuart Bishop
Date:
Subject: Re: BUG #7500: hot-standby replica crash after an initial rsync