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 1kToXc-0007G1-Es for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Oct 2020 15:54:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kToXb-0006xt-B6 for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Oct 2020 15:54:43 +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 1kToXa-0006xl-9c for pgsql-hackers@lists.postgresql.org; Sat, 17 Oct 2020 15:54:43 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kToXW-00063L-0e for pgsql-hackers@postgresql.org; Sat, 17 Oct 2020 15:54:41 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 8B499E41; Sat, 17 Oct 2020 11:54:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 17 Oct 2020 11:54:33 -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=PV7+2lh8ipE0F9P5y Ccvak4rpr/836D2KShPRwnqvio=; b=lQGWYYd6gJC54+0EFE131QZvHlO40teS/ ft4LVbf5rN8POipcF/em1DkGF+b0KIjOUCGsr/KkIlCeEZj6k/C8hvRVkQrWvOCg PE1OfrhQDn08zVdbyD0tQBF4pjLSKB5iSCBQziIfOM9+x1Q3cXJjZpYwJomhyR41 R1Q1SWFMY38+5RZytw3fFNlCNwY0W4IQ9fvGZE3c8VF311PItYqnRemoLF8VzrDa 2MoS2sAlLmquPNSY4+sQ6Bt0ITbGb+4d80UDgrmNFdC1Wswm5d9znemJC51lP3TA Y03TcqEr8A/Z8b3zCXzyMLFIMlk7q/Sxxnn+HswsOI0JpHO3nSS3Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrieejgdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtuggjfgesthdtredttdervdenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvefgleevgeeujeeghfegteeghfegheeifeehheelteetiedu ieeihffggfehffetnecukfhppeduledtrdelhedrudelrddugeeknecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhv hhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 1F8EA306467E; Sat, 17 Oct 2020 11:54:32 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 93EB22A14CB; Sat, 17 Oct 2020 12:54:29 -0300 (-03) Date: Sat, 17 Oct 2020 12:54:29 -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: <20201017155429.GA9862@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-17, Amit Langote wrote: > Hmm, I don't see ri_PartitionCheckExpr as being a piece of routing > information, because it's primarily meant to be used when inserting > *directly* into a partition, although it's true we do initialize it in > routing target partitions too in some cases. > > Also, ChildToRootMap was introduced by the trigger transition table > project, not tuple routing. I think we misjudged this when we added > PartitionToRootMap to PartitionRoutingInfo, because it doesn't really > belong there. This patch fixes that by removing PartitionToRootMap. > > RootToPartitionMap and the associated partition slot is the only piece > of extra information that is needed by tuple routing target relations. Well, I was thinking on making the ri_PartitionInfo be about partitioning in general, not just specifically for partition tuple routing. Maybe Heikki is right that it may end up being simpler to remove ri_PartitionInfo altogether. It'd just be a couple of additional pointers in ResultRelInfo after all. (Remember that we wanted to get rid of fields specific to only certain kinds of RTEs in RangeTblEntry for example, to keep things cleanly separated, although that project eventually found its demise for other reasons.) > As I said in my previous email, I don't see how we can make > initializing the map any lazier than it already is. If a partition > has a different tuple descriptor than the root table, then we know for > sure that any tuples that are routed to it will need to be converted > from the root tuple format to its tuple format, so we might as well > build the map when the ResultRelInfo is built. If no tuple lands into > a partition, we would neither build its ResultRelInfo nor the map. > With the current arrangement, if the map field is NULL, it simply > means that the partition has the same tuple format as the root table. I see -- makes sense. > On Fri, Oct 16, 2020 at 11:45 PM Alvaro Herrera wrote: > > 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? > > No. ExecFindPartition() directly calls ExecInitRoutingInfo() only for > reused update result relations, that too, only the first time a tuple > lands into such a partition. For the subsequent tuples that land into > the same partition, ExecFindPartition() will be able to find that > ResultRelInfo in the proute->partitions[] array. All ResultRelInfos > in that array are assumed to have been processed by > ExecInitRoutingInfo(). Doh, right, sorry, I was misreading the if/else maze there.