Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled.

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled.
Date: 2018-07-05 11:15:42
Message-ID: 5B3DFDDE.2020803@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

(2018/07/04 19:11), Ashutosh Bapat wrote:
> On Wed, Jul 4, 2018 at 3:36 PM, Etsuro Fujita
> <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>>
>> I don't produce a test case where the plan is an Append with Gather
>> subplans, but I'm not sure that it's a good thing to allow us to consider
>> such a plan because in that plan, each Gather would try to grab its own pool
>> of workers. Am I missing something?
>
> If the overall join can not use parallelism, having individual child
> joins use parallel query might turn out to be efficient even if done
> one child at a time. Parallel append drastically reduces the cases
> where something like could be useful, but I don't think we can
> theoretically eliminate the need for such a plan.

In the case where scanjoin_target_parallel_safe=false, we actually will
consider such parallel paths using the existing partial paths for the
parent appendrel in the code path shown in a previous email (note: we
would already have done generate_partitionwise_join_paths or
set_append_rel_pathlist for the parent appendrel in query_planner.) For
such a parallel path, we might need to do a projection in the Gather
node for generating the SRF-free scan/join target, but I think that
would be still efficient. So, I'm not sure that we really need to
create child Gathers and generate an Append with those Gathers, as you
mentioned.

Another thing I noticed is: actually, we don't produce an Append with
child Gathers in apply_scanjoin_target_to_paths, which I thought we
would do that in the case of scanjoin_target_parallel_safe=false, but I
noticed I was wrong. Sorry for that. The reason is because in that
case, even if we create new partial Append paths with child Gathers, we
don't run generate_gatehr_paths for the newly created partial paths at
the end of that function shown below, since the parent's
consider_parallel flag is set to false in that case:

/*
* Consider generating Gather or Gather Merge paths. We must only
do this
* if the relation is parallel safe, and we don't do it for child
rels to
* avoid creating multiple Gather nodes within the same plan. We
must do
* this after all paths have been generated and before
set_cheapest, since
* one of the generated paths may turn out to be the cheapest one.
*/
if (rel->consider_parallel && !IS_OTHER_REL(rel))
generate_gather_paths(root, rel, false);

Best regards,
Etsuro Fujita

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2018-07-05 11:20:27 Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled.
Previous Message Andrew Gierth 2018-07-05 10:45:52 Re: Should contrib modules install .h files?