Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ejjFc-0002yR-Ni for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2018 10:16:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejjFZ-0000D3-Uv for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2018 10:16:17 +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.84_2) (envelope-from ) id 1ejjFZ-0000Ct-O2 for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2018 10:16:17 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ejjFU-00076U-5n for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2018 10:16:14 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w18AG8Ip002670 for ; Thu, 8 Feb 2018 19:16:08 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 6AF6EEA842B; Thu, 8 Feb 2018 19:16:08 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 60914EA8429; Thu, 8 Feb 2018 19:16:08 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 5D7614006C6; Thu, 8 Feb 2018 19:16:08 +0900 (JST) Message-ID: <5A7C2364.9040700@lab.ntt.co.jp> Date: Thu, 08 Feb 2018 19:16:04 +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: non-bulk inserts and tuple routing References: <8975331d-d961-cbdd-f862-fdd3d97dc2d0@lab.ntt.co.jp> <56c9f77b-830c-4652-233e-a1c5fa5a9938@lab.ntt.co.jp> <8f53a342-e0df-4fc9-7422-c3c3c601117c@lab.ntt.co.jp> <5A69A3B7.10403@lab.ntt.co.jp> <37f7cc10-def8-b2d0-615d-dfe035e7b1ee@lab.ntt.co.jp> <5A70396A.8090400@lab.ntt.co.jp> <8399fd28-07c2-3cbc-f807-f89cdf2f98f5@lab.ntt.co.jp> <5A704055.40207@lab.ntt.co.jp> <5A7443DF.1010408@lab.ntt.co.jp> <14870d0e-d9d4-2ab9-ddfe-182b3c8abfca@lab.ntt.co.jp> <5A783549.4020409@lab.ntt.co.jp> <5A7AD6B5.3020304@lab.ntt.co.jp> In-Reply-To: <5A7AD6B5.3020304@lab.ntt.co.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Amit Langote Cc: pgsql-hackers@lists.postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk (2018/02/07 19:36), Etsuro Fujita wrote: > (2018/02/05 19:43), Etsuro Fujita wrote: >> (2018/02/05 14:34), Amit Langote wrote: >>> Here is the updated version that contains two patches as described >>> above. Here are some minor comments: o On changes to ExecInsert * This might be just my taste, but I think it would be better to (1) change ExecInitPartitionInfo so that it creates and returns a newly-initialized ResultRelInfo for an initialized partition, and (2) rewrite this bit: + /* Initialize partition info, if not done already. */ + ExecInitPartitionInfo(mtstate, resultRelInfo, proute, estate, + leaf_part_index); + /* * Save the old ResultRelInfo and switch to the one corresponding to * the selected partition. */ saved_resultRelInfo = resultRelInfo; resultRelInfo = proute->partitions[leaf_part_index]; + Assert(resultRelInfo != NULL); to something like this (I would say the same thing to the copy.c changes): /* * Save the old ResultRelInfo and switch to the one corresponding to * the selected partition. */ saved_resultRelInfo = resultRelInfo; resultRelInfo = proute->partitions[leaf_part_index]; if (resultRelInfo == NULL); { /* Initialize partition info. */ resultRelInfo = ExecInitPartitionInfo(mtstate, saved_resultRelInfo, proute, estate, leaf_part_index); } This would make ExecInitPartitionInfo more simple because it can assume that the given partition has not been initialized yet. o On changes to execPartition.h * Please add a brief decsription about partition_oids to the comments for this struct. @@ -91,6 +91,7 @@ typedef struct PartitionTupleRouting { PartitionDispatch *partition_dispatch_info; int num_dispatch; + Oid *partition_oids; That's it. Best regards, Etsuro Fujita