Re: why not parallel seq scan for slow functions

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: why not parallel seq scan for slow functions
Date: 2017-07-11 20:20:21
Message-ID: CAMkU=1zMC1PAjOeFYUifXWpYg4MUo_SrdjWcf-UVRcvKrsnUew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 10, 2017 at 9:51 PM, Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:

>
>
> In below function, we always multiply the target->cost.per_tuple with
> path->rows, but in case of gather it should multiply this with
> subpath->rows
>
> apply_projection_to_path()
> ....
>
> path->startup_cost += target->cost.startup - oldcost.startup;
> path->total_cost += target->cost.startup - oldcost.startup +
> (target->cost.per_tuple - oldcost.per_tuple) * path->rows;
>
>
> So because of this high projection cost the seqpath and parallel path
> both have fuzzily same cost but seqpath is winning because it's
> parallel safe.
>

I think you are correct. However, unless parallel_tuple_cost is set very
low, apply_projection_to_path never gets called with the Gather path as an
argument. It gets ruled out at some earlier stage, presumably because it
assumes the projection step cannot make it win if it is already behind by
enough.

So the attached patch improves things, but doesn't go far enough.

Cheers,

Jeff

Attachment Content-Type Size
subpath_projection_cost.patch application/octet-stream 677 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Rofail 2017-07-11 22:26:18 Re: GSoC 2017: Foreign Key Arrays
Previous Message Tom Lane 2017-07-11 19:39:14 Re: BUG #14738: ALTER SERVER for foregin servers not working