Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> writes:
> [ 0001-Open-partitioned-tables-during-Append-initialization.patch ]
I took a look at this. While I'm in agreement with the general idea of
holding open the partitioned relations' relcache entries throughout the
query, I do not like anything about this patch:
* It seems to be outright broken for the case that any of the partitioned
relations are listed in nonleafResultRelations. If we're going to do it
like this, we have to open every one of the partrels regardless of that.
(I wonder whether we couldn't lose PlannedStmt.nonleafResultRelations
altogether, in favor of merging the related code in InitPlan with this.
That existing code is already a mighty ugly wart, and this patch makes
it worse by adding new, related warts elsewhere.)
* You've got *far* too much intimate knowledge of the possible callers
in ExecOpenAppendPartitionedTables.
Personally, what I would have this function do is return a List of
the opened Relation pointers, and add a matching function to run through
such a List and close the entries again, and make the callers responsible
for stashing the List pointer in an appropriate field in their planstate.
Or maybe what we should do is drop ExecLockNonLeafAppendTables/
ExecOpenAppendPartitionedTables entirely and teach InitPlan to do it.
regards, tom lane