On Thu, 7 Apr 2022 at 20:28, Amit Langote <amitlangot...@gmail.com> wrote: > Here's an updated version. In Particular, I removed > part_prune_results list from PortalData, in favor of anything that > needs to look at the list can instead get it from the CachedPlan > (PortalData.cplan). This makes things better in 2 ways:
Thanks for making those changes. I'm not overly familiar with the data structures we use for planning around plans between the planner and executor, but storing the pruning results in CachedPlan seems pretty bad. I see you've stashed it in there and invented a new memory context to stop leaks into the cache memory. Since I'm not overly familiar with these structures, I'm trying to imagine why you made that choice and the best I can come up with was that it was the most convenient thing you had to hand inside CheckCachedPlan(). I don't really have any great ideas right now on how to make this better. I wonder if GetCachedPlan() should be changed to return some struct that wraps up the CachedPlan with some sort of executor prep info struct that we can stash the list of PartitionPruneResults in, and perhaps something else one day. Some lesser important stuff that I think could be done better. * Are you also able to put meaningful comments on the PartitionPruneResult struct in execnodes.h? * In create_append_plan() and create_merge_append_plan() you have the same code to set the part_prune_index. Why not just move all that code into make_partition_pruneinfo() and have make_partition_pruneinfo() return the index and append to the PlannerInfo.partPruneInfos List? * Why not forboth() here? i = 0; foreach(stmtlist_item, portal->stmts) { PlannedStmt *pstmt = lfirst_node(PlannedStmt, stmtlist_item); PartitionPruneResult *part_prune_result = part_prune_results ? list_nth(part_prune_results, i) : NULL; i++; * It would be good if ReleaseExecutorLocks() already knew the RTIs that were locked. Maybe the executor prep info struct I mentioned above could also store the RTIs that have been locked already and allow ReleaseExecutorLocks() to just iterate over those to release the locks. David