From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc Mitchell <marcm@eisolution.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: IN subselects and index / seq_scan question....
Date: Mon, 18 Nov 2002 22:43:52 -0500
Message-ID: <17248.1037677432@sss.pgh.pa.us> (raw)
In-Reply-To: <013901c28f62$a7379580$7c01050a@marcmdelltop>
References: <20021112221500.D17277@mail.libertyrms.com>
<200211130317.gAD3HPq21380@candle.pha.pa.us>
<20021113075638.E5763@mail.libertyrms.com>
<20021118143411.W30738@mail.libertyrms.com>
<013901c28f62$a7379580$7c01050a@marcmdelltop>
"Marc Mitchell" <marcm@eisolution.com> writes:
> I am having an optimization problem with queries that include IN clauses
> and subselects.
The optimizer currently has no clue at all about dealing with
"IN (subselect)", and always converts it into the worst sort of
nested-loop plan. I'm hoping to do something about that for 7.4, but
it's only pie-in-the-sky today. In the meantime, the conventional
wisdom is to convert your query into an EXISTS() test instead of an IN()
test. This is still nested-loop, but not as bad --- the clause you push
down into the EXISTS() has a shot at using an index. I believe the
details are in the FAQ.
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-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, marcm@eisolution.com
Subject: Re: IN subselects and index / seq_scan question....
In-Reply-To: <17248.1037677432@sss.pgh.pa.us>
References: <20021112221500.D17277@mail.libertyrms.com> <200211130317.gAD3HPq21380@candle.pha.pa.us> <20021113075638.E5763@mail.libertyrms.com> <20021118143411.W30738@mail.libertyrms.com> <013901c28f62$a7379580$7c01050a@marcmdelltop> <17248.1037677432@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