From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-performance@postgresql.org
Subject: Re: Planner reluctant to start from subquery
Date: Wed, 01 Feb 2006 14:34:24 -0500
Message-ID: <3759.1138822464@sss.pgh.pa.us> (raw)
In-Reply-To: <43E0AA7E.EE98.0025.0@wicourts.gov>
References: <43E0AA7E.EE98.0025.0@wicourts.gov>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> We do have a few queries where PostgreSQL is several orders of
> magnitude slower. It appears that the reason it is choosing a bad plan
> is that it is reluctant to start from a subquery when there is an outer
> join in the FROM clause.
AFAICT this case doesn't really hinge on the outer join at all. The
problem is that EXISTS subqueries aren't well optimized. I would have
expected an equivalent IN clause to work better. In fact, I'm not
clear why the planner isn't finding the cheapest plan (which it does
estimate as cheapest) from the IN version you posted. What PG version
is this exactly?
> ... The third query is the fastest, but isn't
> portable enough for our mixed environment.
Not really relevant to the problem, but what's wrong with it? Looks
like standard SQL to me.
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov
Subject: Re: Planner reluctant to start from subquery
In-Reply-To: <3759.1138822464@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