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 1faege-0006KD-0W for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Jul 2018 10:07:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1faegb-0005lS-Uh for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Jul 2018 10:06:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1faegb-0005lK-OH for pgsql-hackers@lists.postgresql.org; Wed, 04 Jul 2018 10:06:57 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1faegX-0006mo-1a for pgsql-hackers@postgresql.org; Wed, 04 Jul 2018 10:06:57 +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 w64A6m1w031087; Wed, 4 Jul 2018 19:06:48 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 4465B6399C6; Wed, 4 Jul 2018 19:06:48 +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 2F1806399A8; Wed, 4 Jul 2018 19:06:48 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 2839E400CFD; Wed, 4 Jul 2018 19:06:48 +0900 (JST) Message-ID: <5B3C9C33.6030203@lab.ntt.co.jp> Date: Wed, 04 Jul 2018 19:06:43 +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.j p> In-Reply-To: <5B39F47B.10707@lab.ntt.co.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Robert Haas Cc: Ashutosh Bapat , 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/02 18:46), Etsuro Fujita wrote: > (2018/06/22 23:58), Robert Haas wrote: >> And, in general, it seems to me that we want >> to produce the right outputs at the lowest possible level of the plan >> tree. For instance, suppose that one of the relations being scanned >> is not parallel-safe but the others are. Then, we could end up with a >> plan like this: >> >> Append >> -> Seq Scan on temp_rela >> -> Gather >> -> Parallel Seq Scan on thing1 >> -> Gather >> -> Parallel Seq Scan on thing2 >> >> If a projection is required to convert the row type expression, we >> certainly want that to get pushed below the Gather, not to happen at >> the Gather level itself. > > IIUC, we currently don't consider such a plan for partition-wise join; > we'll only consider gathering partial paths for the parent appendrel. While updating the patch, I noticed that I'm wrong here. IIUC, apply_scanjoin_target_to_paths would allow us to consider such an Append for a partitioned relation when scanjoin_target_parallel_safe=false, as it generates new Append paths by recursively adjusting all partitions for which we call generate_gather_paths in that case as shown below: /* * If the scan/join target is not parallel-safe, partial paths cannot * generate it. */ if (!scanjoin_target_parallel_safe) { /* * Since we can't generate the final scan/join target, this is our * last opportunity to use any partial paths that exist. We don't do * this if the case where the target is parallel-safe, since we will * be able to generate superior paths by doing it after the final * scan/join target has been applied. * * Note that this may invalidate rel->cheapest_total_path, so we must * not rely on it after this point without first calling set_cheapest. */ generate_gather_paths(root, rel, false); /* Can't use parallel query above this level. */ rel->partial_pathlist = NIL; rel->consider_parallel = false; } 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? Best regards, Etsuro Fujita