From: Michael Paesold <mpaesold@gmx.at>
To: Bruno Wolff III <bruno@wolff.to>
To: Jeremiah Elliott <jelliott@artcobell.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: slow query - where not in
Date: Fri, 28 Mar 2003 17:53:46 +0100
Message-ID: <028e01c2f54a$9af3d010$3201a8c0@beeblebrox> (raw)
References: <200303280938.50382.jelliott@artcobell.com>
<20030328155933.GA10761@wolff.to>
Bruno Wolff III <bruno@wolff.to> wrote:
> Jeremiah Elliott <jelliott@artcobell.com> wrote:
> > here is the query that is killing me:
> >
> > select shoporder from sodetailtabletrans where shoporder not in(select
> > shoporder from soheadertable)
>
> If there are no null values for shoporder in soheadertable or
> sodetailtabletrans you can use not exists instead of not in:
> select shoporder from sodetailtabletrans where shoporder not exists(select
> shoporder from soheadertable)
I think this should rather be:
SELECT shoporder FROM sodetailtabletrans
WHERE NOT EXISTS (
SELECT 1 FROM soheadertable
WHERE soheadertable.shoporder = sodetailtabletrans.shoporder
)
Regards,
Michael Paesold
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-performance@postgresql.org
Cc: mpaesold@gmx.at, bruno@wolff.to, jelliott@artcobell.com
Subject: Re: slow query - where not in
In-Reply-To: <028e01c2f54a$9af3d010$3201a8c0@beeblebrox>
References: <200303280938.50382.jelliott@artcobell.com> <20030328155933.GA10761@wolff.to> <028e01c2f54a$9af3d010$3201a8c0@beeblebrox>
* 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