Re: allow partial union-all and improve parallel subquery costing - Mailing list pgsql-hackers

From Ronan Dunklau
Subject Re: allow partial union-all and improve parallel subquery costing
Date
Msg-id 2718932.eWMxsFeAN2@aivenronan
Whole thread Raw
In response to Re: allow partial union-all and improve parallel subquery costing  (Luc Vlaming <luc@swarm64.com>)
Responses Re: allow partial union-all and improve parallel subquery costing  (Daniel Gustafsson <daniel@yesql.se>)
List pgsql-hackers
Le lundi 12 avril 2021, 14:01:36 CEST Luc Vlaming a écrit :
> Here's an improved and rebased patch. Hope the description helps some
> people. I will resubmit it to the next commitfest.
>

Hello Luc,

I've taken a look at this patch, and while I don't fully understand its
implications here are a couple remarks.

I think you should add a test demonstrating the use of the new partial append
path you add, for example using your base query:

explain (costs off)
select sum(two) from
(
select *, 1::int  from tenk1 a
union all
select *, 1::bigint  from tenk1 b
) t
;

I'm not sure I understand why the subquery scan rows estimate has not been
accounted like you propose before, because the way it's done as of now
basically doubles the estimate for the subqueryscan, since we account for it
already being divided by it's number of workers, as mentioned in cost_append:

/*
 * Apply parallel divisor to subpaths.  Scale the number of rows
 * for each partial subpath based on the ratio of the parallel
 * divisor originally used for the subpath to the one we adopted.
 * Also add the cost of partial paths to the total cost, but
 * ignore non-partial paths for now.
 */

Do we have other nodes for which we make this assumption ?

Also, adding a partial path comprised only of underlying partial paths might
not be enough: maybe we should add one partial path even in the case of mixed
partial / nonpartial paths like it's done in add_paths_to_append_rel ?

Regards,

--
Ronan Dunklau





pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: Avoiding data loss with synchronous replication
Next
From: John Naylor
Date:
Subject: Re: truncating timestamps on arbitrary intervals