Re: IN subselects and index / seq_scan question....

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc Mitchell" <marcm(at)eisolution(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: IN subselects and index / seq_scan question....
Date: 2002-11-19 03:43:52
Message-ID: 17248.1037677432@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Marc Mitchell" <marcm(at)eisolution(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Bruno Wolff III 2002-11-19 14:07:58 Re: Confused about user permissions and pg_hba.conf
Previous Message Graham Wilson 2002-11-19 01:41:34 Confused about user permissions and pg_hba.conf