hsyuan commented on a change in pull request #1440: [CALCITE-2166] Cumulative 
cost of RelSubset.best RelNode is increased…
URL: https://github.com/apache/calcite/pull/1440#discussion_r322065101
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
 ##########
 @@ -344,15 +344,29 @@ void propagateCostImprovements0(VolcanoPlanner planner, 
RelMetadataQuery mq,
       return;
     }
     try {
-      final RelOptCost cost = planner.getCost(rel, mq);
-      if (cost.isLt(bestCost)) {
-        LOGGER.trace("Subset cost improved: subset [{}] cost was {} now {}", 
this, bestCost, cost);
+      RelOptCost cost = planner.getCost(rel, mq);
+      boolean updateBest = cost.isLt(bestCost);
+
+      // Best rel's cost is increased, we need to search for new best rel
+      if (rel == best && bestCost.isLt(cost)) {
+        updateBest = true;
 
 Review comment:
   In what case do you think the replaced rel may still not be the best one?

----------------------------------------------------------------
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