Re: partition routing layering in nodeModifyTable.c
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Daniel Gustafsson <daniel@yesql.se>,
Etsuro Fujita <etsuro.fujita@gmail.com>, Andres Freund <andres@anarazel.de>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-10-14T09:04:06Z
Lists: pgsql-hackers
On 14/10/2020 09:44, Amit Langote wrote: > I like the idea of storing the ResultRelInfo in ForeignScanState, but > it would be better if we can document the fact that an FDW may not > reliably access until IterateDirectModify(). That's because, setting > it in ExecInitForeignScan() will mean *all* result relations must be > initialized during ExecInitModifyTable(), which defies my > lazy-ResultRelInfo-initiailization proposal. As to why why I'm > pushing that proposal, consider that when we'll get the ability to use > run-time pruning for UPDATE/DELETE with [1], initializing all result > relations before initializing the plan tree will mean most of those > ResultRelInfos will be unused, because run-time pruning that occurs > when the plan tree is initialized (and/or when it is executed) may > eliminate most but a few result relations. > > I've attached a diff to v17-0001 to show one way of delaying setting > ForeignScanState.resultRelInfo. The BeginDirectModify function does a lot of expensive things, like opening a connection to the remote server. If we want to optimize run-time pruning, I think we need to avoid calling BeginDirectModify for pruned partitions altogether. I pushed this without those delay-setting-resultRelInfo changes. But we can revisit those changes with the run-time pruning optimization patch. I'll continue with the last couple of patches in this thread. - Heikki
Commits
-
Fix initialization of es_result_relations in EvalPlanQualStart().
- 22b73d3cb0b5 14.0 landed
-
Remove PartitionRoutingInfo struct.
- fb5883da8615 14.0 landed
-
Revise child-to-root tuple conversion map management.
- 6973533650c0 14.0 landed
-
Clean up code to resolve the "root target relation" in nodeModifyTable.c
- f49b85d783f6 14.0 landed
-
Refactor code for cross-partition updates to a separate function.
- c5b097f8fa69 14.0 landed
-
Remove es_result_relation_info from EState.
- a04daa97a433 14.0 landed
-
Include result relation info in direct modify ForeignScan nodes.
- 178f2d560dde 14.0 landed
-
Create ResultRelInfos later in InitPlan, index them by RT index.
- 1375422c7826 14.0 landed