Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fb2JW-0001KV-2h for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Jul 2018 11:20:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fb2JU-0003JM-91 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Jul 2018 11:20:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fb2JT-0003JF-Uj for pgsql-hackers@lists.postgresql.org; Thu, 05 Jul 2018 11:20:40 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fb2JQ-0002m3-9x for pgsql-hackers@postgresql.org; Thu, 05 Jul 2018 11:20:38 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w65BKWnj001327; Thu, 5 Jul 2018 20:20:32 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 8E0DB639ACE; Thu, 5 Jul 2018 20:20:32 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 7937D639ACD; Thu, 5 Jul 2018 20:20:32 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 7427A400D02; Thu, 5 Jul 2018 20:20:32 +0900 (JST) Message-ID: <5B3DFEFB.1080007@lab.ntt.co.jp> Date: Thu, 05 Jul 2018 20:20:27 +0900 From: Etsuro Fujita User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. References: <5AF2E09F.9060208@lab.ntt.co.jp> <5AF440C2.3040805@lab.ntt.co.jp> <5AF59415.10309@lab.ntt.co.jp> <5AFC0865.8050802@lab.ntt.co.jp> <5AFD6580.5090308@lab.ntt.co.jp> <5AFE81CC.8000508@lab.ntt.co.jp> <5B17C5EC.1090602@lab.ntt.co.jp> <5B1E5071.1000704@lab.ntt.co.jp> <5B23A964.9020800@lab.ntt.co.jp> <5B28FB19.3090809@lab.ntt.co.jp> <5B39F47B.10707@lab.ntt.co.jp> <5B3C9C33.6030203@lab.ntt.co.jp> <5B3DFDDE.2020803@lab.ntt.co.jp> In-Reply-To: <5B3DFDDE.2020803@lab.ntt.co.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Ashutosh Bapat Cc: Robert Haas , Rajkumar Raghuwanshi , pgsql-hackers X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk (2018/07/05 20:15), Etsuro Fujita wrote: > (2018/07/04 19:11), Ashutosh Bapat wrote: >> On Wed, Jul 4, 2018 at 3:36 PM, Etsuro Fujita >> 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); One thing to add is: ISTM we need some cleanup for apply_scanjoin_target_to_paths. Best regards, Etsuro Fujita