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

avamingli 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 78fef498264 Remove Upstream Assertion in Cloudberry's Parallel UNION 
codes.
78fef498264 is described below

commit 78fef498264c13036626f1b414f34320748f1cc6
Author: Zhang Mingli <[email protected]>
AuthorDate: Mon Jul 14 23:04:26 2025 +0800

    Remove Upstream Assertion in Cloudberry's Parallel UNION codes.
    
    This commit addresses the scenario where paths have parallel_workers set
    to 0, but contain subpaths with parallel_workers greater than 0. This
    case is valid and enables our CBDB to maximize parallel execution where
    feasible, enhancing overall performance in query processing.
    
    explain(costs off) SELECT * FROM (SELECT AVG(a) as a FROM
    dml_union_r UNION SELECT AVG(b) as a FROM dml_union_s) foo;
                               QUERY PLAN
    -----------------------------------------------------------------------
     Unique
       Group Key: (avg(dml_union_r.a))
       ->  Sort
             Sort Key: (avg(dml_union_r.a))
             ->  Append
                   ->  Finalize Aggregate
                         ->  Gather Motion 6:1  (slice1; segments: 6)
                               ->  Partial Aggregate
                                     ->  Parallel Seq Scan on dml_union_r
                   ->  Finalize Aggregate
                         ->  Gather Motion 6:1  (slice2; segments: 6)
                               ->  Partial Aggregate
                                     ->  Parallel Append
                                           ->  Seq Scan on
    dml_union_s_1_prt_3 dml_union_s_2
                                           ->  Seq Scan on
    dml_union_s_1_prt_4 dml_union_s_3
                                           ->  Seq Scan on
    dml_union_s_1_prt_5 dml_union_s_4
                                           ->  Seq Scan on
    dml_union_s_1_prt_6 dml_union_s_5
                                           ->  Seq Scan on
    dml_union_s_1_prt_7 dml_union_s_6
                                           ->  Seq Scan on
    dml_union_s_1_prt_8 dml_union_s_7
                                           ->  Seq Scan on
    dml_union_s_1_prt_9 dml_union_s_8
                                           ->  Seq Scan on
    dml_union_s_1_prt_10 dml_union_s_9
                                           ->  Seq Scan on
    dml_union_s_1_prt_11 dml_union_s_10
                                           ->  Parallel Seq Scan on
    dml_union_s_1_prt_2 dml_union_s_1
                                           ->  Parallel Seq Scan on
    dml_union_s_1_prt_def dml_union_s_11
     Optimizer: Postgres query optimizer
    (25 rows)
    
    Authored-by: Zhang Mingli [email protected]
---
 src/backend/optimizer/prep/prepunion.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/backend/optimizer/prep/prepunion.c 
b/src/backend/optimizer/prep/prepunion.c
index 243585fc308..ffaaea30b9c 100644
--- a/src/backend/optimizer/prep/prepunion.c
+++ b/src/backend/optimizer/prep/prepunion.c
@@ -710,7 +710,16 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo 
*root,
 
                        parallel_workers = Max(parallel_workers, 
path->parallel_workers);
                }
+#if 0
+               /*
+                * CBDB_PARALLEL:
+                * Unlike upstream, this scenario can occur when there are 
paths with
+                * parallel_workers set to 0, but have subpaths with 
parallel_workers > 0.
+                * This is a valid case that allows our Cloudberry
+                * to maximize parallel execution where possible.
+                */
                Assert(parallel_workers > 0);
+#endif
 
                /*
                 * If the use of parallel append is permitted, always request 
at least
@@ -726,7 +735,12 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo 
*root,
                        parallel_workers = Min(parallel_workers,
                                                                   
max_parallel_workers_per_gather);
                }
+#if 0
+               /*
+                * See above comments.
+                */
                Assert(parallel_workers > 0);
+#endif
 
                ppath = (Path *)
                        create_append_path(root, result_rel, NIL, 
partial_pathlist,


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

Reply via email to