From: Joe Conway <mail@joeconway.com>
To: Becky Neville <rebecca.neville@yale.edu>
Cc: andrew@libertyrms.info
Cc: pgsql-performance@postgresql.org
Subject: Re: NOT IN doesn't use index? (fwd)
Date: Sat, 03 May 2003 12:31:12 -0700
Message-ID: <3EB41900.5010407@joeconway.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0305031505370.9098-100000@newt.zoo.cs.yale.edu>
References: <Pine.LNX.4.44.0305031505370.9098-100000@newt.zoo.cs.yale.edu>
Becky Neville wrote:
> Well I think you answered my question already, but just in case
> here are the explain results again and the query follows (I warned, it is
> long.) And I did run VACUUM ANALYZE beforehand.
[snipped ugly query with three NOT IN clauses]
Hmmm, no surprise that's slow. How are those three lists of constants
generated? One idea is to recast this as a left join with a FROM clause
subselect, e.g.
select
uabopen_srat_code
from
uabopen u left join
(select '1F' as uabopen_srat_code union all
'1FD' union all
'3A' ...) as ss
on u.uabopen_srat_code = ss.uabopen_srat_code
where ss.uabopen_srat_code is null;
But I'm not sure that will be much quicker. If the list of
uabopen_srat_code you're filtering on comes from one of the other
tables, you might be able to do better -- back to the question above,
how is that list generated? What do the other table look like?
Joe
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: mail@joeconway.com, rebecca.neville@yale.edu, andrew@libertyrms.info
Subject: Re: NOT IN doesn't use index? (fwd)
In-Reply-To: <3EB41900.5010407@joeconway.com>
References: <Pine.LNX.4.44.0305031505370.9098-100000@newt.zoo.cs.yale.edu> <3EB41900.5010407@joeconway.com>
* 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