danny0405 commented on a change in pull request #1703: [CALCITE-2450] Normalize 
RexCall predicates when computing digest
URL: https://github.com/apache/calcite/pull/1703#discussion_r362355423
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
 ##########
 @@ -120,24 +121,23 @@ public static EnumerableHashJoin create(
       }
     }
 
+    RelOptCostFactory costFactory = planner.getCostFactory();
     // Cheaper if the smaller number of rows is coming from the LHS.
     // Model this by adding L log L to the cost.
     final double rightRowCount = right.estimateRowCount(mq);
     final double leftRowCount = left.estimateRowCount(mq);
-    if (Double.isInfinite(leftRowCount)) {
-      rowCount = leftRowCount;
-    } else {
-      rowCount += Util.nLogN(leftRowCount);
-    }
-    if (Double.isInfinite(rightRowCount)) {
-      rowCount = rightRowCount;
-    } else {
-      rowCount += rightRowCount;
+    if (Double.isInfinite(leftRowCount) || Double.isInfinite(rightRowCount)) {
+      return costFactory.makeInfiniteCost();
     }
     if (isSemiJoin()) {
-      return planner.getCostFactory().makeCost(rowCount, 0, 
0).multiplyBy(.01d);
+      // For semi- and anti- the right input is hashed
+      rowCount += rightRowCount * 1.1d;
+      return costFactory.makeCost(rowCount, 0, 0).multiplyBy(.01d);
     } else {
-      return planner.getCostFactory().makeCost(rowCount, 0, 0);
+      // Lots of plans assumed the left join was hashed, so
+      // we adjust a cost accordingly
+      rowCount += leftRowCount * 1.1d;
+      return costFactory.makeCost(rowCount, 0, 0);
 
 Review comment:
   Why a hash cost is `row_cnt * 1.1` ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to