Re: Improve planner cost estimations for alternative subplans

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Alexey Bashtanov <bashtanov(at)imap(dot)cc>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improve planner cost estimations for alternative subplans
Date: 2020-06-18 01:21:58
Message-ID: CAAKRu_Yx8o_jrg1RLGwd-0mbAEzJQhPQOUgmW0aDqVnw1mYvcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 5, 2020 at 9:08 AM Alexey Bashtanov <bashtanov(at)imap(dot)cc> wrote:

>
> In [1] we found a situation where it leads to a suboptimal plan,
> as it bloats the overall cost into large figures,
> a decision related to an outer part of the plan look negligible to the
> planner,
> and as a result it doesn't elaborate on choosing the optimal one.
>
>
Did this geometric average method result in choosing the desired plan for
this case?

> The patch is to fix it. Our linear model for costs cannot quite accommodate
> the piecewise linear matter of alternative subplans,
> so it is based on ugly heuristics and still cannot be very precise,
> but I think it's better than the current one.
>
> Thoughts?
>
>
Is there another place in planner where two alternatives are averaged
together and that cost is used?

To me, it feels a little bit weird that we are averaging together the
startup cost of a plan which will always have a 0 startup cost and a
plan that will always have a non-zero startup cost and the per tuple
cost of a plan that will always have a negligible per tuple cost and one
that might have a very large per tuple cost.

I guess it feels different because instead of comparing alternatives you
are blending them.

I don't have any academic basis for saying that the alternatives costs
shouldn't be averaged together for use in the rest of the plan, so I
could definitely be wrong.

--
Melanie Plageman

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2020-06-18 01:29:27 Re: Review for GetWALAvailability()
Previous Message David G. Johnston 2020-06-18 00:17:26 Re: DROP relation IF EXISTS Docs and Tests - Bug Fix