>From Preetham Poluparthi <preetha...@apache.org>:

Preetham Poluparthi has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20104 )

Change subject: [ASTERIXDB-3600][COMP] cardinality improvements (ne joins)
......................................................................

[ASTERIXDB-3600][COMP] cardinality improvements (ne joins)

- user model changes: no
- storage format changes: no
- interface changes: no

Ext-ref: MB-66327

Change-Id: I1e3e1970775a4ad5f9770f8337246ba30874f8f5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20104
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Preetham Poluparthi <preetha...@apache.org>
Reviewed-by: <murali.kris...@couchbase.com>
---
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.008.plan
M 
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/pushdown/other-pushdowns/other-pushdowns.015.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.10.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/cardinality-estimation/join-queries/join-queries.8.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.14.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.04.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.12.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.009.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.007.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.16.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.010.plan
M 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.plan
13 files changed, 163 insertions(+), 113 deletions(-)

Approvals:
  murali.kris...@couchbase.com: Looks good to me, but someone else must approve
  Preetham Poluparthi: Looks good to me, approved
  Jenkins: Verified; Verified




diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
index 34584c9..47e5c6d 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/cbo/Stats.java
@@ -62,6 +62,7 @@
 import 
org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression;
 import 
org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
 import 
org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
@@ -69,6 +70,7 @@
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator;
+import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.LimitOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator;
 import 
org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator;
@@ -170,18 +172,16 @@
                 return 0.5;
             }

-            if 
(!(joinExpr.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.EQ))) {
-                return 0.5; // this may not be accurate obviously!
-            } // we can do all relops here and other joins such as interval 
joins and spatial joins, the compile time might increase a lot
-
             boolean unnestOp1 = 
joinEnum.findUnnestOp(joinEnum.leafInputs.get(idx1 - 1));
             boolean unnestOp2 = 
joinEnum.findUnnestOp(joinEnum.leafInputs.get(idx2 - 1));
             boolean unnestOp = unnestOp1 || unnestOp2;
+            boolean okOp = acceptableOp(joinExpr.getFunctionIdentifier());
             Index.SampleIndexDetails idxDetails1 = (Index.SampleIndexDetails) 
index1.getIndexDetails();
             Index.SampleIndexDetails idxDetails2 = (Index.SampleIndexDetails) 
index2.getIndexDetails();
             if (((idxDetails1.getSourceCardinality() < 
idxDetails1.getSampleCardinalityTarget())
                     || (idxDetails2.getSourceCardinality() < 
idxDetails2.getSampleCardinalityTarget())
-                    || exprUsedVars.size() > 2) && !unnestOp) { //* if there 
are more than 2 variables, it is not a simple join like r.a op s.a
+                    || 
(!(joinExpr.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.EQ)))
+                    || exprUsedVars.size() > 2) && !unnestOp && okOp) { //* if 
there are more than 2 variables, it is not a simple join like r.a op s.a
                 double sels = 
findJoinSelFromSamples(joinEnum.leafInputs.get(idx1 - 1),
                         joinEnum.leafInputs.get(idx2 - 1), index1, index2, 
joinExpr, jOp);
                 if (sels == 0.0) {
@@ -195,6 +195,28 @@
         }
     }

+    private boolean acceptableOp(FunctionIdentifier functionIdentifier) {
+        if (functionIdentifier.equals(AlgebricksBuiltinFunctions.NEQ)) {
+            return true;
+        }
+        if (functionIdentifier.equals(AlgebricksBuiltinFunctions.LT)) {
+            return true;
+        }
+        if (functionIdentifier.equals(AlgebricksBuiltinFunctions.GT)) {
+            return true;
+        }
+        if (functionIdentifier.equals(AlgebricksBuiltinFunctions.GE)) {
+            return true;
+        }
+        if (functionIdentifier.equals(AlgebricksBuiltinFunctions.LE)) {
+            return true;
+        }
+        if (functionIdentifier.equals(BuiltinFunctions.IF_MISSING_OR_NULL)) { 
// added this for q16 in CH2
+            return true;
+        }
+        return false;
+    }
+
     private double naiveJoinSelectivity(List<LogicalVariable> exprUsedVars, 
double card1, double card2, int idx1,
             int idx2, boolean unnestOp1, boolean unnestOp2) throws 
AlgebricksException {
         ILogicalOperator leafInput;
@@ -254,9 +276,9 @@
     private double findJoinSelFromSamples(ILogicalOperator left, 
ILogicalOperator right, Index index1, Index index2,
             AbstractFunctionCallExpression joinExpr, JoinOperator join) throws 
AlgebricksException {
         AbstractBinaryJoinOperator abjoin = join.getAbstractJoinOp();
-        Pair<ILogicalOperator, Double> leftOutput = 
replaceDataSourceWithSample(left, index1);
+        Pair<ILogicalOperator, Double> leftOutput = 
replaceDataSourceWithSample(left, index1, joinExpr);
         abjoin.getInputs().get(0).setValue(leftOutput.getFirst());
-        Pair<ILogicalOperator, Double> rightOutput = 
replaceDataSourceWithSample(right, index2);
+        Pair<ILogicalOperator, Double> rightOutput = 
replaceDataSourceWithSample(right, index2, joinExpr);
         abjoin.getInputs().get(1).setValue(rightOutput.getFirst());
         abjoin.getCondition().setValue(joinExpr);
         List<List<IAObject>> result = runSamplingQuery(optCtx, abjoin);
@@ -265,9 +287,17 @@
         return sel;
     }

-    private Pair<ILogicalOperator, Double> 
replaceDataSourceWithSample(ILogicalOperator op, Index index)
-            throws AlgebricksException {
+    private Pair<ILogicalOperator, Double> 
replaceDataSourceWithSample(ILogicalOperator op, Index index,
+            AbstractFunctionCallExpression joinExpr) throws 
AlgebricksException {
         ILogicalOperator selOp = 
OperatorManipulationUtil.bottomUpCopyOperators(op);
+        if 
(!(joinExpr.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.EQ))) {
+            // add a limit operator to restrict the number of tuples on each 
side of the join to 1000
+            AsterixConstantValue cnstVal = new AsterixConstantValue(new 
AInt64(1000));
+            ConstantExpression constantExpression = new 
ConstantExpression(cnstVal);
+            LimitOperator lo = new LimitOperator(constantExpression, false);
+            lo.getInputs().add(new MutableObject<>(selOp));
+            selOp = lo;
+        }
         // must set all the Sel operators to be true, otherwise we will be 
multiplying the single table sels also here.
         storeSelectConditionsAndMakeThemTrue(selOp, null);
         ILogicalOperator parent = 
joinEnum.findDataSourceScanOperatorParent(selOp);
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/cardinality-estimation/join-queries/join-queries.8.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/cardinality-estimation/join-queries/join-queries.8.plan
index 3eb913a..4fd759b 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/cardinality-estimation/join-queries/join-queries.8.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/cardinality-estimation/join-queries/join-queries.8.plan
@@ -1,42 +1,42 @@
-distribute result [$$119] [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6741.88]
+distribute result [$$119] [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, 
total-cost: 7030.27]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 
6741.88]
+  exchange [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 
7030.27]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$119] <- [{"n_name": $$n_name, "revenue": $$132}] project: 
[$$119] [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 6741.88]
+    assign [$$119] <- [{"n_name": $$n_name, "revenue": $$132}] project: 
[$$119] [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 7030.27]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 
6741.88]
+      exchange [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 
7030.27]
       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
         group by ([$$n_name := $$142]) decor ([]) {
                   aggregate [$$132] <- [global-sql-sum-serial($$141)] 
[cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
                   -- AGGREGATE  |LOCAL|
                     nested tuple source [cardinality: 0.0, doc-size: 0.0, 
op-cost: 0.0, total-cost: 0.0]
                     -- NESTED_TUPLE_SOURCE  |LOCAL|
-               } [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 
6741.88]
+               } [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, total-cost: 
7030.27]
         -- EXTERNAL_GROUP_BY[$$142]  |PARTITIONED|
-          exchange [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6703.4]
+          exchange [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6919.69]
           -- HASH_PARTITION_EXCHANGE [$$142]  |PARTITIONED|
             group by ([$$142 := $$120]) decor ([]) {
                       aggregate [$$141] <- 
[local-sql-sum-serial(numeric-multiply($$139, numeric-subtract(1, $$140)))] 
[cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
                       -- AGGREGATE  |LOCAL|
                         nested tuple source [cardinality: 0.0, doc-size: 0.0, 
op-cost: 0.0, total-cost: 0.0]
                         -- NESTED_TUPLE_SOURCE  |LOCAL|
-                   } [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6703.4]
+                   } [cardinality: 24.0, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6919.69]
             -- EXTERNAL_GROUP_BY[$$120]  |PARTITIONED|
-              exchange [cardinality: 38.48, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6664.92]
+              exchange [cardinality: 110.58, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6809.11]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                project ([$$139, $$140, $$120]) [cardinality: 38.48, doc-size: 
45.0, op-cost: 0.0, total-cost: 6664.92]
+                project ([$$139, $$140, $$120]) [cardinality: 110.58, 
doc-size: 45.0, op-cost: 0.0, total-cost: 6809.11]
                 -- STREAM_PROJECT  |PARTITIONED|
-                  exchange [cardinality: 38.48, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6664.92]
+                  exchange [cardinality: 110.58, doc-size: 45.0, op-cost: 0.0, 
total-cost: 6809.11]
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                    join (eq($$130, $$128)) [cardinality: 38.48, doc-size: 
45.0, op-cost: 63.48, total-cost: 6664.92]
+                    join (eq($$130, $$128)) [cardinality: 110.58, doc-size: 
45.0, op-cost: 135.58, total-cost: 6809.11]
                     -- HYBRID_HASH_JOIN [$$130][$$128]  |PARTITIONED|
-                      exchange [cardinality: 38.48, doc-size: 40.0, op-cost: 
0.0, total-cost: 6512.96]
+                      exchange [cardinality: 110.58, doc-size: 40.0, op-cost: 
0.0, total-cost: 6512.96]
                       -- HASH_PARTITION_EXCHANGE [$$130]  |PARTITIONED|
-                        project ([$$139, $$140, $$130]) [cardinality: 38.48, 
doc-size: 40.0, op-cost: 0.0, total-cost: 6512.96]
+                        project ([$$139, $$140, $$130]) [cardinality: 110.58, 
doc-size: 40.0, op-cost: 0.0, total-cost: 6512.96]
                         -- STREAM_PROJECT  |PARTITIONED|
-                          exchange [cardinality: 38.48, doc-size: 40.0, 
op-cost: 0.0, total-cost: 6512.96]
+                          exchange [cardinality: 110.58, doc-size: 40.0, 
op-cost: 0.0, total-cost: 6512.96]
                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                            join (and(eq($$133, $$127), eq($$130, $$131))) 
[cardinality: 38.48, doc-size: 40.0, op-cost: 1035.18, total-cost: 6512.96]
+                            join (and(eq($$133, $$127), eq($$130, $$131))) 
[cardinality: 110.58, doc-size: 40.0, op-cost: 1035.18, total-cost: 6512.96]
                             -- HYBRID_HASH_JOIN [$$133, $$131][$$127, $$130]  
|PARTITIONED|
                               exchange [cardinality: 6010.65, doc-size: 10.0, 
op-cost: 0.0, total-cost: 6005.0]
                               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/pushdown/other-pushdowns/other-pushdowns.015.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/pushdown/other-pushdowns/other-pushdowns.015.plan
index 29e8edc..8aae0e3 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/pushdown/other-pushdowns/other-pushdowns.015.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/column/pushdown/other-pushdowns/other-pushdowns.015.plan
@@ -1,20 +1,20 @@
-distribute result [$$52] [cardinality: 2.1, doc-size: 2.0, op-cost: 0.0, 
total-cost: 12.0]
+distribute result [$$52] [cardinality: 4.0, doc-size: 2.0, op-cost: 0.0, 
total-cost: 12.0]
 -- DISTRIBUTE_RESULT  |UNPARTITIONED|
-  exchange [cardinality: 2.1, doc-size: 2.0, op-cost: 0.0, total-cost: 12.0]
+  exchange [cardinality: 4.0, doc-size: 2.0, op-cost: 0.0, total-cost: 12.0]
   -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
-    assign [$$52] <- [{"$1": $$57}] project: [$$52] [cardinality: 2.1, 
doc-size: 2.0, op-cost: 0.0, total-cost: 12.0]
+    assign [$$52] <- [{"$1": $$57}] project: [$$52] [cardinality: 4.0, 
doc-size: 2.0, op-cost: 0.0, total-cost: 12.0]
     -- ASSIGN  |UNPARTITIONED|
-      aggregate [$$57] <- [agg-sql-sum($$60)] [cardinality: 2.1, doc-size: 
2.0, op-cost: 0.0, total-cost: 12.0]
+      aggregate [$$57] <- [agg-sql-sum($$60)] [cardinality: 4.0, doc-size: 
2.0, op-cost: 0.0, total-cost: 12.0]
       -- AGGREGATE  |UNPARTITIONED|
-        exchange [cardinality: 2.1, doc-size: 2.0, op-cost: 0.0, total-cost: 
12.0]
+        exchange [cardinality: 4.0, doc-size: 2.0, op-cost: 0.0, total-cost: 
12.0]
         -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
-          aggregate [$$60] <- [agg-sql-count($$50)] [cardinality: 2.1, 
doc-size: 2.0, op-cost: 0.0, total-cost: 12.0]
+          aggregate [$$60] <- [agg-sql-count($$50)] [cardinality: 4.0, 
doc-size: 2.0, op-cost: 0.0, total-cost: 12.0]
           -- AGGREGATE  |PARTITIONED|
-            project ([$$50]) [cardinality: 2.1, doc-size: 2.0, op-cost: 0.0, 
total-cost: 12.0]
+            project ([$$50]) [cardinality: 4.0, doc-size: 2.0, op-cost: 0.0, 
total-cost: 12.0]
             -- STREAM_PROJECT  |PARTITIONED|
-              exchange [cardinality: 2.1, doc-size: 2.0, op-cost: 0.0, 
total-cost: 12.0]
+              exchange [cardinality: 4.0, doc-size: 2.0, op-cost: 0.0, 
total-cost: 12.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                join (eq($$55, $$56)) [cardinality: 2.1, doc-size: 2.0, 
op-cost: 4.0, total-cost: 12.0]
+                join (eq($$55, $$56)) [cardinality: 4.0, doc-size: 2.0, 
op-cost: 4.0, total-cost: 12.0]
                 -- HYBRID_HASH_JOIN [$$55][$$56]  |PARTITIONED|
                   exchange [cardinality: 2.0, doc-size: 1.0, op-cost: 0.0, 
total-cost: 2.0]
                   -- HASH_PARTITION_EXCHANGE [$$55]  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.04.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.04.plan
index c7bc448..5d4a832 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.04.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.04.plan
@@ -1,20 +1,20 @@
-distribute result [$$51] [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 819.76]
+distribute result [$$51] [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 1710.17]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
819.76]
+  exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1710.17]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$51] <- [{"n_nationkey": $$58, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 819.76]
+    assign [$$51] <- [{"n_nationkey": $$58, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 1710.17]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
819.76]
+      exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1710.17]
       -- SORT_MERGE_EXCHANGE [$$58(ASC), $$56(ASC), $$55(ASC) ]  |PARTITIONED|
-        order (ASC, $$58) (ASC, $$56) (ASC, $$55) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 0.0, total-cost: 819.76]
+        order (ASC, $$58) (ASC, $$56) (ASC, $$55) [cardinality: 166.67, 
doc-size: 15.0, op-cost: 0.0, total-cost: 1710.17]
         -- STABLE_SORT [$$58(ASC), $$56(ASC), $$55(ASC)]  |PARTITIONED|
-          exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
+          exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            project ([$$58, $$56, $$55]) [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 480.0]
+            project ([$$58, $$56, $$55]) [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 480.0]
             -- STREAM_PROJECT  |PARTITIONED|
-              exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
+              exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                join (and(eq($$55, $$58), eq($$56, $$66))) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 190.0, total-cost: 480.0]
+                join (and(eq($$55, $$58), eq($$56, $$66))) [cardinality: 
166.67, doc-size: 15.0, op-cost: 190.0, total-cost: 480.0]
                 -- HYBRID_HASH_JOIN [$$55, $$66][$$58, $$56]  |PARTITIONED|
                   exchange [cardinality: 150.0, doc-size: 5.0, op-cost: 0.0, 
total-cost: 150.0]
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.10.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.10.plan
index a12dde6..7b44ce5 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.10.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.10.plan
@@ -1,20 +1,20 @@
-distribute result [$$51] [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 789.76]
+distribute result [$$51] [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 1680.17]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
789.76]
+  exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1680.17]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$51] <- [{"n_nationkey": $$58, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 789.76]
+    assign [$$51] <- [{"n_nationkey": $$58, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 1680.17]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
789.76]
+      exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1680.17]
       -- SORT_MERGE_EXCHANGE [$$58(ASC), $$56(ASC), $$55(ASC) ]  |PARTITIONED|
-        order (ASC, $$58) (ASC, $$56) (ASC, $$55) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 0.0, total-cost: 789.76]
+        order (ASC, $$58) (ASC, $$56) (ASC, $$55) [cardinality: 166.67, 
doc-size: 15.0, op-cost: 0.0, total-cost: 1680.17]
         -- STABLE_SORT [$$58(ASC), $$56(ASC), $$55(ASC)]  |PARTITIONED|
-          exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
+          exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            project ([$$58, $$56, $$55]) [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 450.0]
+            project ([$$58, $$56, $$55]) [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 450.0]
             -- STREAM_PROJECT  |PARTITIONED|
-              exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
+              exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                join (and(eq($$55, $$58), eq($$56, $$66))) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 180.0, total-cost: 450.0]
+                join (and(eq($$55, $$58), eq($$56, $$66))) [cardinality: 
166.67, doc-size: 15.0, op-cost: 180.0, total-cost: 450.0]
                 -- HYBRID_HASH_JOIN [$$55, $$66][$$58, $$56]  |PARTITIONED|
                   exchange [cardinality: 150.0, doc-size: 5.0, op-cost: 0.0, 
total-cost: 150.0]
                   -- RANDOM_PARTITION_EXCHANGE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.12.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.12.plan
index f440f13..8fc259c 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.12.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.12.plan
@@ -1,16 +1,16 @@
-distribute result [$$51] [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 914.76]
+distribute result [$$51] [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 1805.17]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
914.76]
+  exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1805.17]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$51] <- [{"n_nationkey": $$58, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 914.76]
+    assign [$$51] <- [{"n_nationkey": $$58, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 1805.17]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
914.76]
+      exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1805.17]
       -- SORT_MERGE_EXCHANGE [$$58(ASC), $$56(ASC), $$55(ASC) ]  |PARTITIONED|
-        order (ASC, $$58) (ASC, $$56) (ASC, $$55) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 0.0, total-cost: 914.76]
+        order (ASC, $$58) (ASC, $$56) (ASC, $$55) [cardinality: 166.67, 
doc-size: 15.0, op-cost: 0.0, total-cost: 1805.17]
         -- STABLE_SORT [$$58(ASC), $$56(ASC), $$55(ASC)]  |PARTITIONED|
-          exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 575.0]
+          exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 575.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            join (eq($$55, $$58)) [cardinality: 58.0, doc-size: 15.0, op-cost: 
160.0, total-cost: 575.0]
+            join (eq($$55, $$58)) [cardinality: 166.67, doc-size: 15.0, 
op-cost: 160.0, total-cost: 575.0]
             -- HYBRID_HASH_JOIN [$$58][$$55]  |PARTITIONED|
               exchange [cardinality: 10.0, doc-size: 10.0, op-cost: 0.0, 
total-cost: 105.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.14.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.14.plan
index 681adee..df5db02 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.14.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.14.plan
@@ -1,20 +1,20 @@
-distribute result [$$51] [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 819.76]
+distribute result [$$51] [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 1710.17]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
819.76]
+  exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1710.17]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$51] <- [{"n_nationkey": $$59, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 819.76]
+    assign [$$51] <- [{"n_nationkey": $$59, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 1710.17]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
819.76]
+      exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1710.17]
       -- SORT_MERGE_EXCHANGE [$$59(ASC), $$56(ASC), $$55(ASC) ]  |PARTITIONED|
-        order (ASC, $$59) (ASC, $$56) (ASC, $$55) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 0.0, total-cost: 819.76]
+        order (ASC, $$59) (ASC, $$56) (ASC, $$55) [cardinality: 166.67, 
doc-size: 15.0, op-cost: 0.0, total-cost: 1710.17]
         -- STABLE_SORT [$$59(ASC), $$56(ASC), $$55(ASC)]  |PARTITIONED|
-          exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
+          exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            project ([$$59, $$56, $$55]) [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 480.0]
+            project ([$$59, $$56, $$55]) [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 480.0]
             -- STREAM_PROJECT  |PARTITIONED|
-              exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
+              exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 480.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                join (and(eq($$55, $$59), eq($$56, $$66))) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 190.0, total-cost: 480.0]
+                join (and(eq($$55, $$59), eq($$56, $$66))) [cardinality: 
166.67, doc-size: 15.0, op-cost: 190.0, total-cost: 480.0]
                 -- HYBRID_HASH_JOIN [$$55, $$66][$$59, $$56]  |PARTITIONED|
                   exchange [cardinality: 150.0, doc-size: 5.0, op-cost: 0.0, 
total-cost: 150.0]
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.16.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.16.plan
index f731a7f..6a2aa6e 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.16.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/join/hash-join-with-redundant-variable/hash-join-with-redundant-variable.16.plan
@@ -1,20 +1,20 @@
-distribute result [$$51] [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 789.76]
+distribute result [$$51] [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 1680.17]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
789.76]
+  exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1680.17]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$51] <- [{"n_nationkey": $$59, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 789.76]
+    assign [$$51] <- [{"n_nationkey": $$59, "s_nationkey": $$56, 
"c_nationkey": $$55}] project: [$$51] [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 1680.17]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
789.76]
+      exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, total-cost: 
1680.17]
       -- SORT_MERGE_EXCHANGE [$$59(ASC), $$56(ASC), $$55(ASC) ]  |PARTITIONED|
-        order (ASC, $$59) (ASC, $$56) (ASC, $$55) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 0.0, total-cost: 789.76]
+        order (ASC, $$59) (ASC, $$56) (ASC, $$55) [cardinality: 166.67, 
doc-size: 15.0, op-cost: 0.0, total-cost: 1680.17]
         -- STABLE_SORT [$$59(ASC), $$56(ASC), $$55(ASC)]  |PARTITIONED|
-          exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
+          exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            project ([$$59, $$56, $$55]) [cardinality: 58.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 450.0]
+            project ([$$59, $$56, $$55]) [cardinality: 166.67, doc-size: 15.0, 
op-cost: 0.0, total-cost: 450.0]
             -- STREAM_PROJECT  |PARTITIONED|
-              exchange [cardinality: 58.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
+              exchange [cardinality: 166.67, doc-size: 15.0, op-cost: 0.0, 
total-cost: 450.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                join (and(eq($$55, $$59), eq($$56, $$66))) [cardinality: 58.0, 
doc-size: 15.0, op-cost: 180.0, total-cost: 450.0]
+                join (and(eq($$55, $$59), eq($$56, $$66))) [cardinality: 
166.67, doc-size: 15.0, op-cost: 180.0, total-cost: 450.0]
                 -- HYBRID_HASH_JOIN [$$55, $$66][$$59, $$56]  |PARTITIONED|
                   exchange [cardinality: 150.0, doc-size: 5.0, op-cost: 0.0, 
total-cost: 150.0]
                   -- RANDOM_PARTITION_EXCHANGE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.007.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.007.plan
index 0195762..fcb9b9d 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.007.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.007.plan
@@ -1,16 +1,16 @@
-distribute result [$$52] [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 22.35]
+distribute result [$$52] [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 39.51]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+  exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$52] <- [{"t1_id": $$53, "t2_id": $$54}] project: [$$52] 
[cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+    assign [$$52] <- [{"t1_id": $$53, "t2_id": $$54}] project: [$$52] 
[cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 
22.35]
+      exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
39.51]
       -- SORT_MERGE_EXCHANGE [$$53(ASC), $$54(ASC) ]  |PARTITIONED|
-        order (ASC, $$53) (ASC, $$54) [cardinality: 2.1, doc-size: 15.0, 
op-cost: 0.0, total-cost: 22.35]
+        order (ASC, $$53) (ASC, $$54) [cardinality: 6.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 39.51]
         -- STABLE_SORT [$$53(ASC), $$54(ASC)]  |PARTITIONED|
-          exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 20.1]
+          exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 24.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            select ($$62) project: [$$53, $$54] [cardinality: 2.1, doc-size: 
15.0, op-cost: 0.0, total-cost: 20.1]
+            select ($$62) project: [$$53, $$54] [cardinality: 6.0, doc-size: 
15.0, op-cost: 0.0, total-cost: 24.0]
             -- STREAM_SELECT  |PARTITIONED|
               window-aggregate [$$62] <- [win-mark-first-missing-impl($$54)] 
partition [$$53] order (DESC, $$54) [cardinality: 2.0, doc-size: 15.0, op-cost: 
0.0, total-cost: 2.0]
               -- WINDOW_STREAM  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.008.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.008.plan
index 77e0c34..b109205 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.008.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.008.plan
@@ -1,16 +1,16 @@
-distribute result [$$52] [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 22.35]
+distribute result [$$52] [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 39.51]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+  exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$52] <- [{"t1_id": $$73, "t2_id": $$54}] project: [$$52] 
[cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+    assign [$$52] <- [{"t1_id": $$73, "t2_id": $$54}] project: [$$52] 
[cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 
22.35]
+      exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
39.51]
       -- SORT_MERGE_EXCHANGE [$$73(ASC), $$54(ASC) ]  |PARTITIONED|
-        order (ASC, $$73) (ASC, $$54) [cardinality: 2.1, doc-size: 15.0, 
op-cost: 0.0, total-cost: 22.35]
+        order (ASC, $$73) (ASC, $$54) [cardinality: 6.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 39.51]
         -- STABLE_SORT [$$73(ASC), $$54(ASC)]  |PARTITIONED|
-          exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 20.1]
+          exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 24.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            select ($$74) project: [$$73, $$54] [cardinality: 2.1, doc-size: 
15.0, op-cost: 0.0, total-cost: 20.1]
+            select ($$74) project: [$$73, $$54] [cardinality: 6.0, doc-size: 
15.0, op-cost: 0.0, total-cost: 24.0]
             -- STREAM_SELECT  |PARTITIONED|
               window-aggregate [$$74] <- [win-mark-first-missing-impl($$54)] 
partition [$$73] order (DESC, $$54) [cardinality: 2.0, doc-size: 15.0, op-cost: 
0.0, total-cost: 2.0]
               -- WINDOW_STREAM  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.009.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.009.plan
index f3eb86d..f9554bc 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.009.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.009.plan
@@ -1,16 +1,16 @@
-distribute result [$$52] [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 22.35]
+distribute result [$$52] [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 39.51]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+  exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$52] <- [{"t1_id": $$53, "t2_id": $$54}] project: [$$52] 
[cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+    assign [$$52] <- [{"t1_id": $$53, "t2_id": $$54}] project: [$$52] 
[cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 
22.35]
+      exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
39.51]
       -- SORT_MERGE_EXCHANGE [$$53(ASC), $$54(ASC) ]  |PARTITIONED|
-        order (ASC, $$53) (ASC, $$54) [cardinality: 2.1, doc-size: 15.0, 
op-cost: 0.0, total-cost: 22.35]
+        order (ASC, $$53) (ASC, $$54) [cardinality: 6.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 39.51]
         -- STABLE_SORT [$$53(ASC), $$54(ASC)]  |PARTITIONED|
-          exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 20.1]
+          exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 24.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            select ($$62) project: [$$53, $$54] [cardinality: 2.1, doc-size: 
15.0, op-cost: 0.0, total-cost: 20.1]
+            select ($$62) project: [$$53, $$54] [cardinality: 6.0, doc-size: 
15.0, op-cost: 0.0, total-cost: 24.0]
             -- STREAM_SELECT  |PARTITIONED|
               window-aggregate [$$62] <- [win-mark-first-missing-impl($$54)] 
partition [$$53] order (DESC, $$54) [cardinality: 2.0, doc-size: 15.0, op-cost: 
0.0, total-cost: 2.0]
               -- WINDOW_STREAM  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.010.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.010.plan
index 457fddb..9cc1130 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.010.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/leftouterjoin/index-only-leftouterjoin/index-only-leftouterjoin.010.plan
@@ -1,16 +1,16 @@
-distribute result [$$52] [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 22.35]
+distribute result [$$52] [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 39.51]
 -- DISTRIBUTE_RESULT  |PARTITIONED|
-  exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+  exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-    assign [$$52] <- [{"t1_id": $$73, "t2_id": $$54}] project: [$$52] 
[cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 22.35]
+    assign [$$52] <- [{"t1_id": $$73, "t2_id": $$54}] project: [$$52] 
[cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 39.51]
     -- ASSIGN  |PARTITIONED|
-      exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, total-cost: 
22.35]
+      exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, total-cost: 
39.51]
       -- SORT_MERGE_EXCHANGE [$$73(ASC), $$54(ASC) ]  |PARTITIONED|
-        order (ASC, $$73) (ASC, $$54) [cardinality: 2.1, doc-size: 15.0, 
op-cost: 0.0, total-cost: 22.35]
+        order (ASC, $$73) (ASC, $$54) [cardinality: 6.0, doc-size: 15.0, 
op-cost: 0.0, total-cost: 39.51]
         -- STABLE_SORT [$$73(ASC), $$54(ASC)]  |PARTITIONED|
-          exchange [cardinality: 2.1, doc-size: 15.0, op-cost: 0.0, 
total-cost: 20.1]
+          exchange [cardinality: 6.0, doc-size: 15.0, op-cost: 0.0, 
total-cost: 24.0]
           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-            select ($$74) project: [$$73, $$54] [cardinality: 2.1, doc-size: 
15.0, op-cost: 0.0, total-cost: 20.1]
+            select ($$74) project: [$$73, $$54] [cardinality: 6.0, doc-size: 
15.0, op-cost: 0.0, total-cost: 24.0]
             -- STREAM_SELECT  |PARTITIONED|
               window-aggregate [$$74] <- [win-mark-first-missing-impl($$54)] 
partition [$$73] order (DESC, $$54) [cardinality: 2.0, doc-size: 15.0, op-cost: 
0.0, total-cost: 2.0]
               -- WINDOW_STREAM  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.plan
index 0a1c6bb..c1343bf 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.plan
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/limit/push-limit-to-primary-scan-select/push-limit-to-primary-scan-select.5.plan
@@ -1,20 +1,20 @@
-distribute result [$$37] [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
+distribute result [$$37] [cardinality: 100.0, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
 -- DISTRIBUTE_RESULT  |UNPARTITIONED|
-  exchange [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, total-cost: 308.0]
+  exchange [cardinality: 100.0, doc-size: 55.19, op-cost: 0.0, total-cost: 
308.0]
   -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
-    limit 2 [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, total-cost: 
308.0]
+    limit 2 [cardinality: 100.0, doc-size: 55.19, op-cost: 0.0, total-cost: 
308.0]
     -- STREAM_LIMIT  |UNPARTITIONED|
-      exchange [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, total-cost: 
308.0]
+      exchange [cardinality: 100.0, doc-size: 55.19, op-cost: 0.0, total-cost: 
308.0]
       -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
-        assign [$$37] <- [{"dblpid": $$38}] project: [$$37] [cardinality: 2.1, 
doc-size: 55.19, op-cost: 0.0, total-cost: 308.0]
+        assign [$$37] <- [{"dblpid": $$38}] project: [$$37] [cardinality: 
100.0, doc-size: 55.19, op-cost: 0.0, total-cost: 308.0]
         -- ASSIGN  |PARTITIONED|
-          limit 2 [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
+          limit 2 [cardinality: 100.0, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
           -- STREAM_LIMIT  |PARTITIONED|
-            project ([$$38]) [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
+            project ([$$38]) [cardinality: 100.0, doc-size: 55.19, op-cost: 
0.0, total-cost: 308.0]
             -- STREAM_PROJECT  |PARTITIONED|
-              exchange [cardinality: 2.1, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
+              exchange [cardinality: 100.0, doc-size: 55.19, op-cost: 0.0, 
total-cost: 308.0]
               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
-                join (eq($$38, $$41)) [cardinality: 2.1, doc-size: 55.19, 
op-cost: 104.0, total-cost: 308.0]
+                join (eq($$38, $$41)) [cardinality: 100.0, doc-size: 55.19, 
op-cost: 104.0, total-cost: 308.0]
                 -- HYBRID_HASH_JOIN [$$38][$$41]  |PARTITIONED|
                   exchange [cardinality: 100.0, doc-size: 27.19, op-cost: 0.0, 
total-cost: 100.0]
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20104
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I1e3e1970775a4ad5f9770f8337246ba30874f8f5
Gerrit-Change-Number: 20104
Gerrit-PatchSet: 8
Gerrit-Owner: murali.kris...@couchbase.com
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Preetham Poluparthi <preetha...@apache.org>
Gerrit-Reviewer: murali.kris...@couchbase.com
Gerrit-MessageType: merged

Reply via email to