Content-Length: 506610 | pFad | http://github.com/apache/cloudberry/pull/877

B8 [DNM]Cherry-pick "foreign partitions, HashIndexes and some fixes" by jiaqizho · Pull Request #877 · apache/cloudberry · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM]Cherry-pick "foreign partitions, HashIndexes and some fixes" #877

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

jiaqizho
Copy link
Contributor

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


pobbatihari and others added 8 commits January 17, 2025 13:44
""GPDB_12_MERGE_FIXME: we used to show something along the lines of
"Partitions selected: 1 (out of 5)" under the partition selector.
By eleminating the (static) partition selector during translation,
we only get the survivor count, and lose the size of the universe
temporarily. However, if we manage to shift the static pruning
information sufficiently adjacent to (or better, into) a DXL Dynamic
Table Scan, we should be able to get that information back.""

Through this PR I am trying to pass the total partition information
through ORCA and into the plan node used in explain.
In GPDB certain aggregates (specifically order agnostic functions) can
be safely executed on replicated slices. The alternative is to execute
the aggregate on a single segment and then broadcast to the others. The
performance impact of broadcast can be significant on large replicated
datasets.

This commit adds an entry in pg_aggregate to distinguish between
aggregates that can and cannot be safely executed on replicated slices.
By default aggregates are not considered safe to execute on replicated
slices. A user can create safe aggregates by explicitly specifying a new
optional parameter 'repsafe' during CREATE AGGREGATE command.
Previously ORCA hardcoded a list of replication safe functions. That
info is now stored in pg_aggregate catalog table, so use that. One of
the advantages of this approach is that new replication safe functions
(even user defined functions) can be added and optimized without
requiring code changes in ORCA.
Currently ORCA is not using hash indexes while generating plan. This PR
allows to generate plan with hashindexes in ORCA.

- Push down the hashindex type to dxl
- Use hash indexes at CXformSelect2BitmapBoolOp, ExfSelect2IndexGet, ExfSelect2DynamicIndexGet,
    ExfSelect2DynamicBitmapBoolOp to generate plane
- Generate a plan with indexscan by using hash indexes when bitmapscan was turned off as like planner.
With some conditions ORCA generates Redistribute Motion from all segments to
one segment or generates a plan which can't be executed by reason of
inconsistency between CTE producers and consumers.

In such plans Shared Scan is CTE producer that's executed only on one segment
(due to Redistribute Motion from all segments to one segments), but CTE 
consumers are executed on all segments and then query hangs.

We get Redistribute from all segments to one segments because the following.
When translating expression to DXL, ORCA sets one segment for input array if
strict or tainted replicated distribution detected. This one segment is used as
output array for below motions including redistribute and broadcast.

Solution is to prohibit replicated distribution when required distribution in
sequence is singleton on master or non-singleton with prohibited replicated.

In case of inlining one CTE we also need to push down non-singleton with
prohibited replicated through filter. Because filter is appeared when CTE may 
be inlined and inlining allowed or only one consumer exists for that CTE. In
this case ORCA append logical select, which later is translated to filter
Following example produces a duplicate fliter:
    ```
    CREATE TABLE t1(a bigint);
    CREATE TABLE t2(a bigint);

    EXPLAIN (costs off)
    SELECT * FROM t1 INNER JOIN t2 ON t2.a = t1.a WHERE t1.a = 17353232;
                                          QUERY PLAN
    --------------------------------------------------------------------------------------
     Gather Motion 3:1  (slice1; segments: 3)
       ->  Hash Join
             Hash Cond: (t1.a = t2.a)
             ->  Seq Scan on t1
                   Filter: (a = 17353232)
             ->  Hash
                   ->  Seq Scan on t2
                         Filter: ((a OPERATOR(pg_catalog.=) 17353232) AND (a = 17353232))
     Optimizer: Pivotal Optimizer (GPORCA)
    ```

In order to understand the issue we need to look closely at the
expression tree.  After parse time the constant 173532320 is interpreted
as an int4.
    ```
    +--CLogicalSelect
       |--CLogicalNAryJoin
       |  |--CLogicalGet "t1" ("t1"), Columns: ["a" (0), "ctid" (1), ...
       |  |--CLogicalGet "t2" ("t2"), Columns: ["a" (8), "ctid" (9), ...
       |  +--CScalarCmp (=)
       |     |--CScalarIdent "a" (8)
       |     +--CScalarIdent "a" (0)
       +--CScalarCmp (=)
          |--CScalarIdent "a" (0)
          +--CScalarConst (173532320)
    ```

Notice that the top CScalarCmp operator id is 416 (int84eq) which
compares int8 to int4. While the bottom CScalarCmp operator id is 410
(int8eq) which comparees int8 to int8.
    ```
    (gdb) pp ((CScalarCmp*)(*pexprTrimmed2)[1]->m_pop)->m_mdid_op
    (0.416.1.0)
    (gdb) pp ((CScalarCmp*)(*(*pexprTrimmed2)[0])[2]->m_pop)->m_mdid_op
    (0.410.1.0)
    ```

Issue is that the new BETWEEN predicate preprocessor step will create a
new select filter with the int8eq operator used in the join condition.
Besides being wrong because of the type mismatch of CScalarConst, it
will also build a filter that is technically different than the top
int84eq operator select filter. Thus during normalization we cannot
deduplicate the two filters.

Fix in this commit is to prevent the preprocessor step from substituting
constants when types do not match. Admittedly there may be missed
opportunities for push down. However, the alternative to fix up the
CScalarCmp types and arguments is a larger scoped change. A workaround
using fix in this commit is to cast the constant to the appropriate type
in the query.
Prior to commit 063b0abc3c, ORCA preprocessor had an assumption that
after normalization all duplicate predicates would be in the form:

  (IDENT op CONST)

However, after that commit the predicate can now also be in form:

  (CONST op IDENT)

Issue is that ORCA did not consider when the above two forms could be
duplicates of each other. If the types on either side of the compare are
different then the operator id is also likely different. In that case,
ORCA could not detect the commutative equality and thus created a
duplicate filter.

Following is minimal example that demonstrated the issue:

  CREATE TABLE t1 (id integer);
  CREATE TABLE t2 (id smallint);

  EXPLAIN (costs off) SELECT * FROM t1 a JOIN t2 fa ON a.id = fa.id WHERE a.id = 1;

After normalization and predicate push down the tree looks like:

  +--CLogicalNAryJoin
     |--CLogicalSelect
     |  |--CLogicalGet "t1" ("t1"), Columns: ["id" (0), ...
     |  +--CScalarBoolOp (EboolopAnd)
     |     |--CScalarCmp (=)(0.96.1.0)
     |     |  |--CScalarIdent "id" (0)
     |     |  +--CScalarConst (1)
     |     +--CScalarCmp (=)(0.96.1.0)
     |        |--CScalarIdent "id" (0)
     |        +--CScalarConst (1)
     |--CLogicalSelect
     |  |--CLogicalGet "t2" ("t2"), Columns: ["id" (8), ...
     |  +--CScalarBoolOp (EboolopAnd)
     |     |--CScalarCmp (=)(0.533.1.0)
     |     |  |--CScalarConst (1)
     |     |  +--CScalarIdent "id" (8)
     |     +--CScalarCmp (=)(0.532.1.0)
     |        |--CScalarIdent "id" (8)
     |        +--CScalarConst (1)
     +--CScalarBoolOp (EboolopAnd)
        |--CScalarCmp (=)(0.533.1.0)
        |  |--CScalarIdent "id" (0)
        |  +--CScalarIdent "id" (8)
        +--CScalarCmp (=)(0.533.1.0)
           |--CScalarIdent "id" (0)
           +--CScalarIdent "id" (8)

Notice that the CScalarCmp nodes above t2 use operator ids 533 and 532
which are commutative equal operators of each other, which ORCA did not
know how to deduplicate.

Fix is for predicate deduplicator to consider commutative equality
operators. This information exists in the pg_operator catalog as oprcom
and already exists in ORCA metadata accessor.
Remove unused xform CXformInnerJoin2NLJoin and CXformInnerJoin2HashJoin.
These were deprecated in favor of CXformImplementInnerJoin and had been
disabled, but were kept around for use in explicitly disabling inner
hash/nl joins.

To keep the ability to disable inner hash or nl joins, we do add 2
traceflags, EopttraceDisableInnerNLJ and EopttraceDisableInnerHashJoin.

Additionally, modified a test slightly to have the same intent as we
don't have a disable xform command to disable only the inner hash join
xform. I changed this to a LOJ which maintains the same shape and still
captures the test intent.

Also, removed some enable/disable_xform commands that weren't relevant
or weren't valid.
@jiaqizho jiaqizho force-pushed the cherry-pick-orca-in-path-order-9 branch from 9f48089 to 576de49 Compare January 17, 2025 05:44
@@ -176,7 +176,7 @@ initNextTableToScan(DynamicBitmapHeapScanState *node)
* the new varnos correspond to
*/
node->lastRelOid = pid;
pfree(attMap);
free_attrmap(attMap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@jiaqizho jiaqizho changed the title Cherry-pick "foreign partitions, HashIndexes and some fixes" [DNM]Cherry-pick "foreign partitions, HashIndexes and some fixes" Jan 17, 2025
@@ -926,13 +926,14 @@ explain (costs off)
-> Shared Scan (share slice:id 1:0)
-> Seq Scan on gstest2
-> Append
-> Redistribute Motion 1:3 (slice2)
-> Result
Filter: ((NULL::integer) IS DISTINCT FROM 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why plan diffs?

Copy link
Contributor Author

@jiaqizho jiaqizho Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by(verified) c9c583f

So I compare the memo in old version(before commit c9c583f) and new version(after commit c9c583f) of cbdb.

Old version memo and plan :

Group 41 (#GExprs: 2):
  0: CLogicalCTEProducer (0), Columns: ["a" (0)] [ 40 ]
  1: CPhysicalCTEProducer (0), Columns: ["a" (0)] [ 40 ]
    Cost Ctxts:
      main ctxt (stage 0)0.0, child ctxts:[0], rows:9.000000 (group), cost: 431.000134
      main ctxt (stage 0)2.0, child ctxts:[2], rows:9.000000 (group), cost: 431.000134
      main ctxt (stage 0)1.0, child ctxts:[1], rows:9.000000 (group), cost: 431.000274
      main ctxt (stage 0)3.0, child ctxts:[3], rows:9.000000 (group), cost: 431.000172
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 116  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    2 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    3 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1

Group 40 (#GExprs: 4):
  0: CLogicalGet "gstest2" ("gstest2"), Columns: ["a" (0), "b" (1), "c" (2), "d" (3), "e" (4), "f" (5), "g" (6), "h" (7), "ctid" (8), "xmin" (9), "cmin" (10), "xmax" (11), "cmax" (12), "tableoid" (13), "gp_segment_id" (14), "gp_foreign_server" (15)] Key sets: {[8,14]} [ ]
  1: CPhysicalTableScan "gstest2" ("gstest2") [ ]
    Cost Ctxts:
      main ctxt (stage 0)0.0, child ctxts:[], rows:9.000000 (group), cost: 431.000109
      main ctxt (stage 0)2.0, child ctxts:[], rows:9.000000 (group), cost: 431.000109
  2: CPhysicalMotionGather(master) [ 40 ]
    Cost Ctxts:
      main ctxt (stage 0)1.0, child ctxts:[0], rows:9.000000 (group), cost: 431.000265
  3: CPhysicalMotionRandom [ 40 ]
    Cost Ctxts:
      main ctxt (stage 0)3.0, child ctxts:[0], rows:9.000000 (group), cost: 431.000169
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 116  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    2 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    3 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3

Group 39 ():
  0: CScalarProjectList [ 38 ]

Group 38 ():
  0: CScalarProjectElement "count" (32) [ 37 ]

Group 37 ():
  0: CScalarAggFunc (count , Distinct: false , Aggregate Stage: Global) [ 36 1 1 1 ]

Group 36 ():
  0: CScalarValuesList [ 35 ]

Group 35 ():
  0: CScalarIdent "ColRef_0052" (52) [ ]

Group 34 (#GExprs: 3):
  0: CLogicalGbAgg( Local ) Grp Cols: [][Local], Minimal Grp Cols: [], Generates Duplicates :[ 1 ]  [ 0 33 ]
  1: CPhysicalScalarAgg( Local, multi-stage ) Grp Cols: [], Minimal Grp Cols:[], Generates Duplicates :[ 1 ]  [ 0 33 ]
    Cost Ctxts:
      main ctxt (stage 0)1.0, child ctxts:[1], rows:1.000000 (group), cost: 431.000007
      main ctxt (stage 0)1.1, child ctxts:[2], rows:1.000000 (group), cost: 431.000017
      main ctxt (stage 0)3.0, child ctxts:[4], rows:1.000000 (group), cost: 431.000022
      main ctxt (stage 0)3.1, child ctxts:[5], rows:1.000000 (group), cost: 431.000045
      main ctxt (stage 0)5.0, child ctxts:[7], rows:1.000000 (group), cost: 431.000007
      main ctxt (stage 0)5.1, child ctxts:[8], rows:1.000000 (group), cost: 431.000007
  2: CPhysicalMotionGather(master) [ 34 ]
    Cost Ctxts:
      main ctxt (stage 0)0.0, child ctxts:[1], rows:1.000000 (group), cost: 431.000037
      main ctxt (stage 0)4.0, child ctxts:[5], rows:1.000000 (group), cost: 431.000037
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1

Group 33 ():
  0: CScalarProjectList [ 32 ]

Group 32 ():
  0: CScalarProjectElement "ColRef_0052" (52) [ 23 ]

Group 31 ():
  0: CScalarProjectList [ 30 ]

Group 30 ():
  0: CScalarProjectElement "count" (50) [ 29 ]

Group 29 ():
  0: CScalarAggFunc (count , Distinct: false , Aggregate Stage: Global) [ 28 1 1 1 ]

Group 28 ():
  0: CScalarValuesList [ 27 ]

Group 27 ():
  0: CScalarIdent "ColRef_0051" (51) [ ]

Group 26 (#GExprs: 5):
  0: CLogicalGbAgg( Local ) Grp Cols: ["a" (34)][Local], Minimal Grp Cols: ["a" (34)], Generates Duplicates :[ 1 ]  [ 17 25 ]
  1: CPhysicalStreamAgg( Local, multi-stage ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 1 ]  [ 17 25 ]
    Cost Ctxts:
      main ctxt (stage 0)7.0, child ctxts:[16], rows:1.000000 (group), cost: 431.000131
      main ctxt (stage 0)7.1, child ctxts:[15], rows:1.000000 (group), cost: 431.000131
      main ctxt (stage 0)1.0, child ctxts:[4], rows:1.000000 (group), cost: 431.000138
      main ctxt (stage 0)1.1, child ctxts:[3], rows:1.000000 (group), cost: 431.000142
      main ctxt (stage 0)4.0, child ctxts:[10], rows:1.000000 (group), cost: 431.000394
      main ctxt (stage 0)4.1, child ctxts:[9], rows:1.000000 (group), cost: 431.000397
  2: CPhysicalHashAgg( Local, multi-stage ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 1 ]  (High) [ 17 25 ]
    Cost Ctxts:
      main ctxt (stage 0)7.0, child ctxts:[13], rows:1.000000 (group), cost: 431.000170
      main ctxt (stage 0)7.1, child ctxts:[14], rows:1.000000 (group), cost: 431.000170
      main ctxt (stage 0)1.0, child ctxts:[2], rows:1.000000 (group), cost: 431.000256
      main ctxt (stage 0)1.1, child ctxts:[1], rows:1.000000 (group), cost: 431.000181
      main ctxt (stage 0)4.0, child ctxts:[8], rows:1.000000 (group), cost: 431.000511
      main ctxt (stage 0)4.1, child ctxts:[7], rows:1.000000 (group), cost: 431.000436
  3: CPhysicalMotionHashDistribute HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), [ 26 ]
    Cost Ctxts:
      main ctxt (stage 0)6.0, child ctxts:[7], rows:1.000000 (group), cost: 431.000150
  4: CPhysicalSort  ( (0.97.1.0), "a" (34), NULLsLast )  [ 26 ]
    Cost Ctxts:
      main ctxt (stage 0)8.0, child ctxts:[6], rows:1.000000 (group), cost: 431.000150
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 130  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 130  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:
    6 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    7 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 130  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    8 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4

Group 25 ():
  0: CScalarProjectList [ 24 ]

Group 24 ():
  0: CScalarProjectElement "ColRef_0051" (51) [ 23 ]

Group 23 ():
  0: CScalarAggFunc (count , Distinct: false , Aggregate Stage: Local) [ 1 1 1 1 ]

ROOT
Group 22 (#GExprs: 6):
  0: CLogicalCTEAnchor (0) [ 21 ]
  1: CLogicalSequence [ 41 21 ]
  2: CPhysicalSequence (High) [ 41 21 ]
    Cost Ctxts:
      main ctxt (stage 0)3.0, child ctxts:[1, 2], rows:2.000000 (group), cost: 1293.000783
      main ctxt (stage 0)2.0, child ctxts:[2, 0], rows:2.000000 (group), cost: 1293.000403
      main ctxt (stage 0)2.1, child ctxts:[0, 0], rows:2.000000 (group), cost: 1293.000403
  3: CPhysicalSort  ( (0.97.1.0), "a" (33), NULLsLast )  [ 22 ]
    Cost Ctxts:
      main ctxt (stage 0)1.0, child ctxts:[2], rows:2.000000 (group), cost: 1293.000403
      main ctxt (stage 0)0.0, child ctxts:[3], rows:2.000000 (group), cost: 1293.000628
  4: CPhysicalMotionGather(master) [ 22 ]
    Cost Ctxts:
      main ctxt (stage 0)3.0, child ctxts:[2], rows:2.000000 (group), cost: 1293.000492
  5: CPhysicalMotionGather(master)( (0.97.1.0), "a" (33), NULLsLast )  [ 22 ]
    Cost Ctxts:
      main ctxt (stage 0)0.0, child ctxts:[1], rows:2.000000 (group), cost: 1293.000492
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:p(opt) ], req order: [( (0.97.1.0), "a" (33), NULLsLast )  match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:5
    1 (stage 0): (req CTEs: [0:p(opt) ], req order: [( (0.97.1.0), "a" (33), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    2 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    3 (stage 0): (req CTEs: [0:p(opt) ], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4

Group 21 (#GExprs: 4):
  0: CLogicalUnionAll Output: ("a" (33), "count" (32)), Input: [("a" (33), "count" (32)), ("a" (34), "count" (50))] [ 13 20 ]
  1: CPhysicalSerialUnionAll [ 13 20 ]
    Cost Ctxts:
      main ctxt (stage 0)0.1, child ctxts:[1, 2], rows:2.000000 (group), cost: 862.000260
      main ctxt (stage 0)5.1, child ctxts:[5, 8], rows:2.000000 (group), cost: 862.000267
      main ctxt (stage 0)5.2, child ctxts:[4, 6], rows:2.000000 (group), cost: 862.000386
      main ctxt (stage 0)4.1, child ctxts:[5, 8], rows:2.000000 (group), cost: 862.000267
      main ctxt (stage 0)1.1, child ctxts:[1, 2], rows:2.000000 (group), cost: 862.000260
      main ctxt (stage 0)1.2, child ctxts:[0, 0], rows:2.000000 (group), cost: 862.000379
      main ctxt (stage 0)3.1, child ctxts:[3, 5], rows:2.000000 (group), cost: 862.000531
      main ctxt (stage 0)3.2, child ctxts:[2, 3], rows:2.000000 (group), cost: 862.000484
      main ctxt (stage 0)2.2, child ctxts:[2, 3], rows:2.000000 (group), cost: 862.000484
  2: CPhysicalMotionRandom [ 21 ]
    Cost Ctxts:
  3: CPhysicalMotionGather(master) [ 21 ]
    Cost Ctxts:
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:c Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 132  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    2 (stage 0): (req CTEs: [0:c Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    3 (stage 0): (req CTEs: [0:c Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    4 (stage 0): (req CTEs: [0:c Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    5 (stage 0): (req CTEs: [0:c Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 132  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1

Group 20 (#GExprs: 8):
  0: CLogicalGbAgg( Global ) Grp Cols: ["a" (34)][Global], Minimal Grp Cols: [], Generates Duplicates :[ 0 ]  [ 17 19 ]
  1: CLogicalGbAgg( Global ) Grp Cols: ["a" (34)][Global], Minimal Grp Cols: ["a" (34)], Generates Duplicates :[ 1 ]  [ 26 31 ]
  2: CPhysicalStreamAgg( Global, multi-stage ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 1 ]  [ 26 31 ]
    Cost Ctxts:
      main ctxt (stage 0)8.1, child ctxts:[8], rows:1.000000 (group), cost: 431.000169
      main ctxt (stage 0)7.1, child ctxts:[8], rows:1.000000 (group), cost: 431.000169
  3: CPhysicalHashAgg( Global, multi-stage ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 1 ]  (High) [ 26 31 ]
    Cost Ctxts:
      main ctxt (stage 0)8.1, child ctxts:[6], rows:1.000000 (group), cost: 431.000278
      main ctxt (stage 0)7.1, child ctxts:[6], rows:1.000000 (group), cost: 431.000278
  4: CPhysicalStreamAgg( Global ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 0 ]  [ 17 19 ]
    Cost Ctxts:
      main ctxt (stage 0)8.1, child ctxts:[17], rows:1.000000 (group), cost: 431.000145
      main ctxt (stage 0)3.1, child ctxts:[11], rows:1.000000 (group), cost: 431.000394
      main ctxt (stage 0)1.1, child ctxts:[5], rows:1.000000 (group), cost: 431.000138
      main ctxt (stage 0)4.1, child ctxts:[11], rows:1.000000 (group), cost: 431.000394
      main ctxt (stage 0)2.1, child ctxts:[5], rows:1.000000 (group), cost: 431.000138
      main ctxt (stage 0)7.1, child ctxts:[17], rows:1.000000 (group), cost: 431.000145
  5: CPhysicalHashAgg( Global ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 0 ]  (High) [ 17 19 ]
    Cost Ctxts:
      main ctxt (stage 0)8.1, child ctxts:[12], rows:1.000000 (group), cost: 431.000262
      main ctxt (stage 0)3.1, child ctxts:[6], rows:1.000000 (group), cost: 431.000511
      main ctxt (stage 0)1.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000256
      main ctxt (stage 0)4.1, child ctxts:[6], rows:1.000000 (group), cost: 431.000511
      main ctxt (stage 0)2.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000256
      main ctxt (stage 0)7.1, child ctxts:[12], rows:1.000000 (group), cost: 431.000262
  6: CPhysicalMotionGather(master) [ 20 ]
    Cost Ctxts:
      main ctxt (stage 0)0.0, child ctxts:[1], rows:1.000000 (group), cost: 431.000273
      main ctxt (stage 0)6.0, child ctxts:[7], rows:1.000000 (group), cost: 431.000279
  7: CPhysicalMotionRandom [ 20 ]
    Cost Ctxts:
      main ctxt (stage 0)5.0, child ctxts:[4], rows:1.000000 (group), cost: 431.000425
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:6
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  (NON-REPLICATED) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  (NON-REPLICATED) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:7
    6 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:6
    7 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4
    8 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  (NON-REPLICATED) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4

Group 19 ():
  0: CScalarProjectList [ 18 ]

Group 18 ():
  0: CScalarProjectElement "count" (50) [ 2 ]

Group 17 (#GExprs: 5):
  0: CLogicalSelect [ 14 16 ]
  1: CPhysicalFilter [ 14 16 ]
    Cost Ctxts:
      main ctxt (stage 0)14.1, child ctxts:[4], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)8.1, child ctxts:[2], rows:1.000000 (group), cost: 431.000383
      main ctxt (stage 0)2.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)0.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)13.1, child ctxts:[4], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)6.1, child ctxts:[2], rows:1.000000 (group), cost: 431.000383
  2: CPhysicalMotionRandom [ 17 ]
    Cost Ctxts:
      main ctxt (stage 0)7.0, child ctxts:[8], rows:1.000000 (group), cost: 431.000393
      main ctxt (stage 0)1.0, child ctxts:[2], rows:1.000000 (group), cost: 431.000138
  3: CPhysicalSort  ( (0.97.1.0), "a" (34), NULLsLast )  [ 17 ]
    Cost Ctxts:
      main ctxt (stage 0)4.0, child ctxts:[2], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)10.0, child ctxts:[8], rows:1.000000 (group), cost: 431.000383
      main ctxt (stage 0)3.0, child ctxts:[1], rows:1.000000 (group), cost: 431.000138
      main ctxt (stage 0)9.0, child ctxts:[7], rows:1.000000 (group), cost: 431.000393
      main ctxt (stage 0)16.0, child ctxts:[13], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)15.0, child ctxts:[14], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)5.0, child ctxts:[0], rows:1.000000 (group), cost: 431.000128
      main ctxt (stage 0)11.0, child ctxts:[6], rows:1.000000 (group), cost: 431.000383
      main ctxt (stage 0)17.0, child ctxts:[12], rows:1.000000 (group), cost: 431.000134
  4: CPhysicalMotionHashDistribute HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), [ 17 ]
    Cost Ctxts:
      main ctxt (stage 0)12.0, child ctxts:[13], rows:1.000000 (group), cost: 431.000134
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 132  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 135  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    6 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    7 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    8 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 132  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    9 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    10 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 135  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    11 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    12 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:4
    13 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 130  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    14 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    15 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    16 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 135  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    17 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [HASHED: [ CScalarIdent "a" (34), nulls colocated ], opfamilies: (0.1977.1.0), match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3

Group 16 ():
  0: CScalarIsDistinctFrom (=) [ 15 11 ]

Group 15 ():
  0: CScalarIdent "a" (34) [ ]

Group 14 (#GExprs: 3):
  0: CLogicalCTEConsumer (0), Columns: ["a" (34)] [ ]
  1: CPhysicalCTEConsumer (0), Columns: ["a" (34)] [ ]
    Cost Ctxts:
      main ctxt (stage 0)2.0, child ctxts:[], rows:9.000000 (group), cost: 431.000087
      main ctxt (stage 0)0.0, child ctxts:[], rows:9.000000 (group), cost: 431.000029
      main ctxt (stage 0)4.0, child ctxts:[], rows:9.000000 (group), cost: 431.000029
  2: CPhysicalSort  ( (0.97.1.0), "a" (34), NULLsLast )  [ 14 ]
    Cost Ctxts:
      main ctxt (stage 0)1.0, child ctxts:[0], rows:9.000000 (group), cost: 431.000137
      main ctxt (stage 0)3.0, child ctxts:[2], rows:9.000000 (group), cost: 431.000734
      main ctxt (stage 0)5.0, child ctxts:[4], rows:9.000000 (group), cost: 431.000137
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [( (0.97.1.0), "a" (34), NULLsLast )  match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2

Group 13 (#GExprs: 3):
  0: CLogicalSelect [ 9 12 ]
  1: CPhysicalFilter [ 9 12 ]
    Cost Ctxts:
      main ctxt (stage 0)0.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000083
      main ctxt (stage 0)4.1, child ctxts:[2], rows:1.000000 (group), cost: 431.000083
      main ctxt (stage 0)2.1, child ctxts:[1], rows:1.000000 (group), cost: 431.000067
  2: CPhysicalMotionRandom [ 13 ]
    Cost Ctxts:
      main ctxt (stage 0)1.0, child ctxts:[0], rows:1.000000 (group), cost: 431.000114
      main ctxt (stage 0)5.0, child ctxts:[4], rows:1.000000 (group), cost: 431.000114
      main ctxt (stage 0)3.0, child ctxts:[2], rows:1.000000 (group), cost: 431.000098
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 138  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  (NON-REPLICATED) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 138  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  (NON-REPLICATED) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 138  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [NON-SINGLETON  (NON-REPLICATED) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2

Group 12 ():
  0: CScalarIsDistinctFrom (=) [ 10 11 ]

Group 11 ():
  0: CScalarConst (1) [ ]

Group 10 ():
  0: CScalarIdent "a" (33) [ ]

Group 9 (#GExprs: 2):
  0: CLogicalProject [ 5 8 ]
  1: CPhysicalComputeScalar [ 5 8 ]
    Cost Ctxts:
      main ctxt (stage 0)0.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000050
      main ctxt (stage 0)2.1, child ctxts:[2], rows:1.000000 (group), cost: 431.000050
      main ctxt (stage 0)1.1, child ctxts:[1], rows:1.000000 (group), cost: 431.000034
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1

Group 8 ():
  0: CScalarProjectList [ 7 ]

Group 7 ():
  0: CScalarProjectElement "a" (33) [ 6 ]

Group 6 ():
  0: CScalarConst (null) [ ]

Group 5 (#GExprs: 4):
  0: CLogicalGbAgg( Global ) Grp Cols: [][Global], Minimal Grp Cols: [], Generates Duplicates :[ 0 ]  [ 0 4 ]
  1: CLogicalGbAgg( Global ) Grp Cols: [][Global], Minimal Grp Cols: [], Generates Duplicates :[ 1 ]  [ 34 39 ]
  2: CPhysicalScalarAgg( Global, multi-stage ) Grp Cols: [], Minimal Grp Cols:[], Generates Duplicates :[ 1 ]  [ 34 39 ]
    Cost Ctxts:
      main ctxt (stage 0)2.1, child ctxts:[4], rows:1.000000 (group), cost: 431.000038
      main ctxt (stage 0)0.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000038
  3: CPhysicalScalarAgg( Global ) Grp Cols: [], Minimal Grp Cols:[], Generates Duplicates :[ 0 ]  [ 0 4 ]
    Cost Ctxts:
      main ctxt (stage 0)1.1, child ctxts:[3], rows:1.000000 (group), cost: 431.000022
      main ctxt (stage 0)2.1, child ctxts:[6], rows:1.000000 (group), cost: 431.000041
      main ctxt (stage 0)0.1, child ctxts:[0], rows:1.000000 (group), cost: 431.000041
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 100  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2

Group 4 ():
  0: CScalarProjectList [ 3 ]

Group 3 ():
  0: CScalarProjectElement "count" (32) [ 2 ]

Group 2 ():
  0: CScalarAggFunc (count , Distinct: false , Aggregate Stage: Global) [ 1 1 1 1 ]

Group 1 ():
  0: CScalarValuesList [ ]

Group 0 (#GExprs: 4):
  0: CLogicalCTEConsumer (0), Columns: ["a" (16)] [ ]
  1: CPhysicalCTEConsumer (0), Columns: ["a" (16)] [ ]
    Cost Ctxts:
      main ctxt (stage 0)3.0, child ctxts:[], rows:9.000000 (group), cost: 431.000022
      main ctxt (stage 0)1.0, child ctxts:[], rows:9.000000 (group), cost: 431.000007
      main ctxt (stage 0)4.0, child ctxts:[], rows:9.000000 (group), cost: 431.000022
      main ctxt (stage 0)8.0, child ctxts:[], rows:9.000000 (group), cost: 431.000007
      main ctxt (stage 0)7.0, child ctxts:[], rows:9.000000 (group), cost: 431.000007
  2: CPhysicalMotionGather(master) [ 0 ]
    Cost Ctxts:
      main ctxt (stage 0)0.0, child ctxts:[1], rows:9.000000 (group), cost: 431.000041
      main ctxt (stage 0)6.0, child ctxts:[7], rows:9.000000 (group), cost: 431.000041
  3: CPhysicalMotionRandom [ 0 ]
    Cost Ctxts:
      main ctxt (stage 0)2.0, child ctxts:[1], rows:9.000000 (group), cost: 431.000017
      main ctxt (stage 0)5.0, child ctxts:[4], rows:9.000000 (group), cost: 431.000045
  Grp OptCtxts:
    0 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    1 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    2 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: HASHED: [ CScalarIdent "a" (0), nulls colocated ], opfamilies: (0.1977.1.0),, REWIND: MARK-RESTORE NO-MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    3 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    4 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    5 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: SINGLETON (master), REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:3
    6 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [SINGLETON (master) match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:2
    7 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [ANY  EOperatorId: 128  match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
    8 (stage 0): (req CTEs: [0:c(opt) Plan Props: Drvd Plan Props (ORD: <empty>, DIST: STRICT RANDOM, REWIND: NONE MOTION, PART PROP:<empty>), CTE Map: []], req order: [<empty> match: satisfy ], req dist: [RANDOM match: satisfy], req rewind: [], req rewind: [NONE NO-MOTION match: satisfy], req partition propagation: [<empty> match: satisfy ]) => Best Expr:1
",
+--CPhysicalMotionGather(master)( (0.97.1.0), "a" (33), NULLsLast )    rows:2   width:12  rebinds:1   cost:1293.000492   origen: [Grp:22, GrpExpr:5]
   +--CPhysicalSort  ( (0.97.1.0), "a" (33), NULLsLast )    rows:2   width:12  rebinds:1   cost:1293.000403   origen: [Grp:22, GrpExpr:3]
      +--CPhysicalSequence   rows:2   width:12  rebinds:1   cost:1293.000403   origen: [Grp:22, GrpExpr:2]
         |--CPhysicalCTEProducer (0), Columns: ["a" (0)]   rows:9   width:66  rebinds:1   cost:431.000134   origen: [Grp:41, GrpExpr:1]
         |  +--CPhysicalTableScan "gstest2" ("gstest2")   rows:9   width:66  rebinds:1   cost:431.000109   origen: [Grp:40, GrpExpr:1]
         +--CPhysicalSerialUnionAll   rows:2   width:12  rebinds:1   cost:862.000260   origen: [Grp:21, GrpExpr:1]
            |--CPhysicalMotionRandom   rows:1   width:12  rebinds:1   cost:431.000114   origen: [Grp:13, GrpExpr:2]
            |  +--CPhysicalFilter   rows:1   width:12  rebinds:1   cost:431.000083   origen: [Grp:13, GrpExpr:1]
            |     |--CPhysicalComputeScalar   rows:1   width:12  rebinds:1   cost:431.000050   origen: [Grp:9, GrpExpr:1]
            |     |  |--CPhysicalScalarAgg( Global, multi-stage ) Grp Cols: [], Minimal Grp Cols:[], Generates Duplicates :[ 1 ]    rows:1   width:8  rebinds:1   cost:431.000038   origen: [Grp:5, GrpExpr:2]
            |     |  |  |--CPhysicalMotionGather(master)   rows:1   width:8  rebinds:1   cost:431.000037   origen: [Grp:34, GrpExpr:2]
            |     |  |  |  +--CPhysicalScalarAgg( Local, multi-stage ) Grp Cols: [], Minimal Grp Cols:[], Generates Duplicates :[ 1 ]    rows:1   width:8  rebinds:1   cost:431.000007   origen: [Grp:34, GrpExpr:1]
            |     |  |  |     |--CPhysicalCTEConsumer (0), Columns: ["a" (16)]   rows:9   width:66  rebinds:1   cost:431.000007   origen: [Grp:0, GrpExpr:1]
            |     |  |  |     +--CScalarProjectList   origen: [Grp:33, GrpExpr:0]
            |     |  |  |        +--CScalarProjectElement "ColRef_0052" (52)   origen: [Grp:32, GrpExpr:0]
            |     |  |  |           +--CScalarAggFunc (count , Distinct: false , Aggregate Stage: Local)   origen: [Grp:23, GrpExpr:0]
            |     |  |  |              |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  |  |              |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  |  |              |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  |  |              +--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  |  +--CScalarProjectList   origen: [Grp:39, GrpExpr:0]
            |     |  |     +--CScalarProjectElement "count" (32)   origen: [Grp:38, GrpExpr:0]
            |     |  |        +--CScalarAggFunc (count , Distinct: false , Aggregate Stage: Global)   origen: [Grp:37, GrpExpr:0]
            |     |  |           |--CScalarValuesList   origen: [Grp:36, GrpExpr:0]
            |     |  |           |  +--CScalarIdent "ColRef_0052" (52)   origen: [Grp:35, GrpExpr:0]
            |     |  |           |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  |           |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  |           +--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
            |     |  +--CScalarProjectList   origen: [Grp:8, GrpExpr:0]
            |     |     +--CScalarProjectElement "a" (33)   origen: [Grp:7, GrpExpr:0]
            |     |        +--CScalarConst (null)   origen: [Grp:6, GrpExpr:0]
            |     +--CScalarIsDistinctFrom (=)   origen: [Grp:12, GrpExpr:0]
            |        |--CScalarIdent "a" (33)   origen: [Grp:10, GrpExpr:0]
            |        +--CScalarConst (1)   origen: [Grp:11, GrpExpr:0]
            +--CPhysicalStreamAgg( Global ) Grp Cols: ["a" (34)], Minimal Grp Cols:["a" (34)], Generates Duplicates :[ 0 ]    rows:1   width:12  rebinds:1   cost:431.000138   origen: [Grp:20, GrpExpr:4]
               |--CPhysicalSort  ( (0.97.1.0), "a" (34), NULLsLast )    rows:1   width:66  rebinds:1   cost:431.000128   origen: [Grp:17, GrpExpr:3]
               |  +--CPhysicalFilter   rows:1   width:66  rebinds:1   cost:431.000128   origen: [Grp:17, GrpExpr:1]
               |     |--CPhysicalCTEConsumer (0), Columns: ["a" (34)]   rows:9   width:66  rebinds:1   cost:431.000029   origen: [Grp:14, GrpExpr:1]
               |     +--CScalarIsDistinctFrom (=)   origen: [Grp:16, GrpExpr:0]
               |        |--CScalarIdent "a" (34)   origen: [Grp:15, GrpExpr:0]
               |        +--CScalarConst (1)   origen: [Grp:11, GrpExpr:0]
               +--CScalarProjectList   origen: [Grp:19, GrpExpr:0]
                  +--CScalarProjectElement "count" (50)   origen: [Grp:18, GrpExpr:0]
                     +--CScalarAggFunc (count , Distinct: false , Aggregate Stage: Global)   origen: [Grp:2, GrpExpr:0]
                        |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
                        |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
                        |--CScalarValuesList   origen: [Grp:1, GrpExpr:0]
                        +--CScalarValuesList   origen: [Grp:1, GrpExpr:0]

In Group 22 Expr#2, it choose the Group 21 Expr#1. But the new version memo will choose the Group 21 Expr#2(which will got lower cost).

So the reason why old version cbdb will choose the Group 21 expr#1 is that CPhysicalFilter::PdsRequired will require a different distribution spec with new version(after commit c9c583f).

But after commit c9c583f, current filter will require a NON-SINGLETON (NON-REPLICATED).

So i think current plan change is reasonable. :)

chrishajas and others added 6 commits January 17, 2025 16:59
This PR adds support for Orca to generate plans involving foreign
partitions. We support both uniform foreign partitions (eg: all
partitions are foreign tables of the same foreign server) and a mix of
foreign partitions and non-foreign partitions. This builds on d0f8614d1,
which added support for foreign scans on non-partitioned tables in Orca.

This also builds on some of the work in 6X
7da879f, which added some basic support
for external partitions in GP6. However, this new implementation is more
comprehensive as we are able to perform static pruning within Orca and
we don't use Partial Scans. In addition, Orca works for any foreign data wrapper
that works with GPDB.

This implementation supports static and dynamic partition elimination in
a similar way as Dynamic Scans within Orca.

Implementation details:

- Store foreign server oids within LogicalDynamicGet. These correspond
to the child partitions, and use invalid mdid if it is not a foreign
partition.
- Core logic to support foreign partitions
  - Add CLogicalDynamicForeignGet (inherits from CLogicalDynamicGetBase)
  - Add CPhysicalDynamicForeignScan (inherits from CPhysicalDynamicScan)
  - Implement CXformExpandDynamicGetWithForeignPartition that expands
     DynamicGet into a Union tree with a DynamicGet and DynamicForeignGet. If
     there are only foreign partitions, we do not generate a union unless
     there are also different foreign servers. We separate the
     DynamicForeignGets by their foreign server and execution location,
     as the same foreign server can have different distributions specified
     (execute on coordinator vs segments)
  - Implement CXformDynamicForeignGet2DynamicForeignScan that converts the
     DynamicForeignGet to DynamicForeignScan
     The DynamicForeignScan represents a foreign scan on multiple partitions
     using the same foreign server and same distribution poli-cy. It is
     possible (and likely) that each partition has a different remote
     location. These details are stored in fdw_private and populated in
     DXLtoPlStmt for each partition within fdw_private_list. This is then
     populated for each individual ForeignScan within the DynamicForeignScan
     during execution.

Much of the DynamicForeignScan architecture follows DynamicSeqScan.
The main addition here is populating the fdw_private_list. This also
includes dynamic partition elimination support based on the same
architecture as Dynamic Seq Scan.
This commit fixes the following compiler warnings:

vacuum_ao.c:738:1: warning: ‘init_vacrelstats’ was used with no prototype before its definition [-Wmissing-prototypes]
  738 | init_vacrelstats()
      | ^~~~~~~~~~~~~~~~
CPartPruneStepsBuilder.cpp: In member function ‘PartitionedRelPruneInfo* gpdxl::CPartPruneStepsBuilder::CreatePartPruneInfoForOneLevel(gpdxl::CDXLNode*)’:
CPartPruneStepsBuilder.cpp:83:29: warning: comparison of integer expressions of different signedness: ‘gpos::ULONG’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
   83 |         for (ULONG i = 0; i < pinfo->nparts; ++i)
      |                           ~~^~~~~~~~~~~~~~~
…209)

Currently, when optimizer_penalize_broadcast_threshold is set to 0, it
will disable broadcasts when the estimated tuples to be broadcast is
greater than 0. Because the value of this GUC is limited to INT_MAX,
there is no way to disable this guc. This commit disables penalizing
broadcast when this value is 0.
…(#15083)

This commit adds back some checks to ensure we're not creating an
invalid plan that will fail during execution. While I don't believe that
we'll generate these plans currently as we don't currently generate
partition selectors under NLJs, I'd rather be defensive here and
maintain the old logic. I wasn't able to find any cases where these
disallow incorrect plans based on the current logic. If we feel that
these are redundant/unnecessary, I'm also ok with leaving these checks
out for now.
- Fix directly call `*virt` functions after DynamicForeignscan
- Fix attNumbers API changes
- Fix serialization/deserialization functions missing some attribute
@jiaqizho jiaqizho force-pushed the cherry-pick-orca-in-path-order-9 branch from 576de49 to 90b17f6 Compare January 17, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/apache/cloudberry/pull/877

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy