From: Tom Lane <tgl@sss.pgh.pa.us>
To: stefan@konink.de
Cc: pgsql-bugs@postgresql.org
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: Wed, 29 Aug 2012 11:20:44 -0400
Message-ID: <10470.1346253644@sss.pgh.pa.us> (raw)
In-Reply-To: <E1T6fYV-0001eM-S3@wrigleys.postgresql.org>
References: <E1T6fYV-0001eM-S3@wrigleys.postgresql.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, stefan@konink.de
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;
In-Reply-To: <10470.1346253644@sss.pgh.pa.us>
References: <E1T6fYV-0001eM-S3@wrigleys.postgresql.org> <10470.1346253644@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox