"Marc Mitchell" <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to