mihaibudiu commented on code in PR #3851:
URL: https://github.com/apache/calcite/pull/3851#discussion_r1678644510


##########
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java:
##########
@@ -982,11 +982,17 @@ void propagateCostImprovements(RelNode rel) {
         if (!relNode.getTraitSet().satisfies(subset.getTraitSet())) {
           continue;
         }
-        if (!cost.isLt(subset.bestCost)) {
+
+        // Update subset best and best's cost when we find a cheaper rel

Review Comment:
   The line commented does not update anything, it just calls continue.
   The comment should say the opposite: if the cost is higher, continue.
   



##########
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java:
##########
@@ -982,11 +982,17 @@ void propagateCostImprovements(RelNode rel) {
         if (!relNode.getTraitSet().satisfies(subset.getTraitSet())) {
           continue;
         }
-        if (!cost.isLt(subset.bestCost)) {
+
+        // Update subset best and best's cost when we find a cheaper rel
+        if (relNode != subset.best && !cost.isLt(subset.bestCost)) {
           continue;
         }
-        // Update subset best cost when we find a cheaper rel or the current
-        // best's cost is changed
+
+        // Update the current best's cost when we find cost is changed
+        if (relNode == subset.best && cost.equals(subset.bestCost)) {

Review Comment:
   First, this is not JavaDoc, it's a regular comment.
   
   Please make the entire comment as simple as possible. 
   
   I still don't understand what the comment says and how it relates to the 
code. Please refer in the comment to variables in the code by name. This 
comparison is for equality, but the comments talks about "smaller". I don't 
understand how the comment describes the code. No need to make a story about 
"I" or "we", just say what the code does.
   



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to