Here's an updated version. In this version, based on a voice discussion with Ashutosh and Jeevan, I adjusted 0001 to combine it with an earlier idea of splitting Gather/Gather Merge path generation out of the function that creates partially aggregated paths. The idea here is that create_ordinary_gather_paths() could first call create_partial_grouping_paths(), then add additional paths which might be partial or non-partial by invoking the partition-wise aggregate logic, then call gather_grouping_paths() and set_cheapest() to finalize the partially grouped rel. Also, I added draft commit messages.
I have added all these three patches in the attached patch-set and rebased my changes over it.
However, I have not yet made this patch-set dependednt on UPPERREL_TLIST changes you have proposed on another mail-thread and thus it has 0001 patch refactoring the scanjoin issue.
0002, 0003 and 0004 are your patches added in this patchset.
0005 and 0006 are further refactoring patches. 0006 adds a GroupPathExtraData which stores mostly child variant data and costs.
0007 is main partitionwise aggregation patch which is then rebased accordingly.
0008 contains testcase and 0009 contains FDW changes.
Let me know if I missed any point to consider while rebasing.
--
Jeevan Chalke Technical Architect, Product Development EnterpriseDB Corporation The Enterprise PostgreSQL Company