Re: Query optimization problem - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Query optimization problem
Date
Msg-id AANLkTi=5pNrtgMRvOywQLd4Jg-Pya89s22pycZxUYvZo@mail.gmail.com
Whole thread Raw
In response to Re: Query optimization problem  (Dimitri Fontaine <dfontaine@hi-media.com>)
Responses Re: Query optimization problem
List pgsql-hackers
On Wed, Jul 28, 2010 at 3:45 AM, Dimitri Fontaine
<dfontaine@hi-media.com> wrote:
>> Even if we understood how to direct the rewriting process, I'm really
>> dubious that it would win often enough to justify the added planning
>> time.  The particular problem here seems narrow enough that solving it
>> on the client side is probably a whole lot easier and cheaper than
>> trying to get the planner to do it.
>
> My overly naive uneducated idea here would be to produce both the plans
> and let the planner evaluate their respective costs. Maybe that's what
> you mean here by "how to direct the rewriting process". Then we don't
> want to generate too many useless plans when you have lots of eclass
> around.

The way the planner is set up, you'd have to plan with qual A, then
repeat the entire process with qual B, and then just for good measure
repeat the process with both quals A and B.  ISTM you'd triple the
planning time if there were even just one case of this in a particular
query.  If you have different ways of generating the same output for a
given rel, you can just throw them all into a bucket and let the
planner work it out.  But here you want to have different paths for
the same relation that generate *different output*, and the planner
doesn't understand that concept.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: page corruption on 8.3+ that makes it to standby
Next
From: Dimitri Fontaine
Date:
Subject: Re: Query optimization problem