On Thu, Mar 1, 2018 at 4:52 PM, Robert Haas <robertmhaas@gmail.com> wrote: > This is not a full review, but I'm out of time for right now.
Another thing I see here now is that create_grouping_paths() and create_child_grouping_paths() are extremely similar. Isn't there some way we can refactor things so that we can reuse the code instead of duplicating it?
Yes. I too observed the same after our re-design.
To avoid code duplication, I am now calling create_grouping_paths() for child relation too.
However, to perform Gather or Gather Merge once we have all partial paths ready, and to avoid too many existing code rearrangement, I am calling try_partitionwise_grouping() before we do any aggregation/grouping on whole relation. By doing this, we will be having all partial paths in partially_grouped_rel and then existing code will do required finalization along with any Gather or Gather Merge, if required.
Please have a look over attached patch-set and let me know if it needs further changes.