Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTQzQ-0004qS-93 for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Oct 2020 14:45:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kTQzO-0002XV-Nm for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Oct 2020 14:45:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTQzO-0002XN-Gg for pgsql-hackers@lists.postgresql.org; Fri, 16 Oct 2020 14:45:50 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kTQzL-00086H-KU for pgsql-hackers@postgresql.org; Fri, 16 Oct 2020 14:45:49 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id D8CC15C0161; Fri, 16 Oct 2020 10:45:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 16 Oct 2020 10:45:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=fWepXRwINBDd6D9nj xkRmZfjaik4+8PFaejYOJVwHS8=; b=mVMAyszfV+Re4W+op+0sjwpqnz/VhWz6i 4lH6RVXPoYKwos3Pd2xgQ9yROsjUuWu/F5boxZGCK/1k4wNWyEWRaFzm5C3lt8en w8swntUVbCz3/ue6bhP3YFQtAlRmNR51i9IeM3YKPEDgUJIA0qCVQWl5evz5hBcT xcQ/PhkVvS71j7Sg69iKDnUUNzQKuLhwSG9sWxQIILdjH0LXZDudw3jwvPozuU/C CLbIUqSYeJ9ODdT8e+vx1KnTxUyx+flJez6AwG6Js6UqSPULRTriDqC7f/khv/++ OY+m5ewuWs8LzcyEDKEY4idk2N6rU6bIHGg22NNwReqo4IIuk1yeg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrieehgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrddutdeirddufeegrddutddtnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (h100-n190-106-134.v8.fangio.net [190.106.134.100]) by mail.messagingengine.com (Postfix) with ESMTPA id B73343064674; Fri, 16 Oct 2020 10:45:44 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 882D32A14D3; Fri, 16 Oct 2020 11:45:41 -0300 (-03) Date: Fri, 16 Oct 2020 11:45:41 -0300 From: Alvaro Herrera To: Amit Langote Cc: Heikki Linnakangas , Daniel Gustafsson , Etsuro Fujita , Andres Freund , PostgreSQL-development Subject: Re: partition routing layering in nodeModifyTable.c Message-ID: <20201016144541.GA26250@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Oct-16, Amit Langote wrote: > On Thu, Oct 15, 2020 at 11:59 PM Heikki Linnakangas wrote: > > On Wed, Oct 14, 2020 at 6:04 PM Heikki Linnakangas wrote: > > And if we removed > > ri_PartitionInfo->pi_PartitionToRootMap, and always used > > ri_ChildToRootMap for it. > > Done in the attached. Hmm... Overall I like the simplification. > > Maybe remove PartitionRoutingInfo struct altogether, and just move its > > fields directly to ResultRelInfo. > > If we do that, we'll end up with 3 notations for the same thing across > releases: In v10 and v11, PartitionRoutingInfos members are saved in > arrays in ModifyTableState, totally detached from the partition > ResultRelInfos. In v12 (3f2393edef), we moved them into ResultRelInfo > but chose to add them into a sub-struct (PartitionRoutingInfo), which > in retrospect was not a great decision. Now if we pull them into > ResultRelInfo, we'll have invented the 3rd notation. Maybe that makes > things hard when back-patching bug-fixes? I don't necessarily agree that PartitionRoutingInfo was such a bad idea. In fact I wonder if we shouldn't move *more* stuff into it (ri_PartitionCheckExpr), and keep struct ResultRelInfo clean of partitioning-related stuff (other than ri_PartitionInfo and ri_PartitionRoot); there are plenty of ResultRelInfos that are not partitions, so I think it makes sense to keep the split. I'm thinking that the ChildToRootMap should continue to be in PartitionRoutingInfo. Maybe what we need in order to keep the initialization "lazy enough" is some inline functions that act as getters, initializing members of PartitionRoutingInfo when first needed. (This would probably need boolean flags, to distinguish "hasn't been set up yet" from "it is not needed for this partition" for each member that requires it). BTW it is curious that ExecInitRoutingInfo is called both in ExecInitPartitionInfo() (from ExecFindPartition when the ResultRelInfo for the partition is not found) *and* from ExecFindPartition again, when the ResultRelInfo for the partition *is* found. Doesn't this mean that ri_PartitionInfo is set up twice for the same partition?