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

 ##########
 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:
   Why we need a decision `rel == best` ? We should always update the best rel 
and cost if we found any. The problem here is that when and how this fix is 
triggered, can you give more explain ?

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