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_r322040644
 
 

 ##########
 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:
   But in this for loop, you have replaced the best `rel` right ? This replaced 
rel may still not be the best one, i didn't find the meaningness to replace it, 
if you want to fix the cost val, just update the cost.

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