This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 78308031f5b Improve handling of distinct partial paths.
78308031f5b is described below

commit 78308031f5b1be930eb5b08759bf003e5954f199
Author: Zhang Mingli <[email protected]>
AuthorDate: Wed Jul 2 15:21:33 2025 +0800

    Improve handling of distinct partial paths.
    
    Skip current partial path if locus does not match.
    
    Authored-by: Zhang Mingli [email protected]
---
 src/backend/cdb/cdbgroupingpaths.c | 40 +++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/backend/cdb/cdbgroupingpaths.c 
b/src/backend/cdb/cdbgroupingpaths.c
index 33d5024579e..2462cd5e9b0 100644
--- a/src/backend/cdb/cdbgroupingpaths.c
+++ b/src/backend/cdb/cdbgroupingpaths.c
@@ -757,28 +757,28 @@ create_two_stage_paths(PlannerInfo *root, 
cdb_agg_planning_context *ctx,
                {
                        Path *path = (Path *)lfirst(lc);
 
-                       if (!cdbpathlocus_collocates_tlist(root, path->locus, 
ctx->group_tles))
+                       if (cdbpathlocus_collocates_tlist(root, path->locus, 
ctx->group_tles))
+                               continue;
+
+                       if (ctx->is_distinct && ctx->can_hash)
                        {
-                               if (ctx->is_distinct && ctx->can_hash)
-                               {
-                                       double dNumGroups = 
estimate_num_groups_on_segment(ctx->dNumGroupsTotal,
-                                                                               
                                                                path->rows,
-                                                                               
                                                                path->locus);
-
-                                       path = (Path *) create_agg_path(root,
-                                                                               
                  ctx->partial_rel,
-                                                                               
                  path,
-                                                                               
                  ctx->partial_grouping_target,
-                                                                               
                  AGG_HASHED,
-                                                                               
                  ctx->hasAggs ? AGGSPLIT_INITIAL_SERIAL : AGGSPLIT_SIMPLE,
-                                                                               
                  parallel_query_use_streaming_hashagg, /* streaming */
-                                                                               
                  ctx->groupClause,
-                                                                               
                  NIL,
-                                                                               
                  ctx->agg_partial_costs,
-                                                                               
                  dNumGroups);
-                               }
-                               add_partial_path(ctx->partial_rel, path);
+                               double dNumGroups = 
estimate_num_groups_on_segment(ctx->dNumGroupsTotal,
+                                                                               
                                                        path->rows,
+                                                                               
                                                        path->locus);
+
+                               path = (Path *) create_agg_path(root,
+                                                                               
          ctx->partial_rel,
+                                                                               
          path,
+                                                                               
          ctx->partial_grouping_target,
+                                                                               
          AGG_HASHED,
+                                                                               
          ctx->hasAggs ? AGGSPLIT_INITIAL_SERIAL : AGGSPLIT_SIMPLE,
+                                                                               
          parallel_query_use_streaming_hashagg, /* streaming */
+                                                                               
          ctx->groupClause,
+                                                                               
          NIL,
+                                                                               
          ctx->agg_partial_costs,
+                                                                               
          dNumGroups);
                        }
+                       add_partial_path(ctx->partial_rel, path);
                }
        }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to