xzj7019 commented on code in PR #21428:
URL: https://github.com/apache/doris/pull/21428#discussion_r1255196550


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java:
##########
@@ -680,11 +680,13 @@ private double estimateGroupByRowCount(List<Expression> 
groupByExpressions, Stat
         }
         int groupByCount = groupByExpressions.size();
         if 
(groupByColStats.values().stream().anyMatch(ColumnStatistic::isUnKnown)) {
+            // if there is group-bys, output row count is 
childStats.getRowCount() * DEFAULT_AGGREGATE_RATIO,
+            // o.w. output row count is 1
+            // example: select sum(A) from T;
             if (groupByCount > 0) {
-                rowCount *= DEFAULT_AGGREGATE_RATIO * 
Math.pow(DEFAULT_AGGREGATE_EXPAND_RATIO, groupByCount - 1);
-            }
-            if (rowCount > childStats.getRowCount()) {
-                rowCount = childStats.getRowCount();
+                rowCount = childStats.getRowCount() * DEFAULT_AGGREGATE_RATIO;

Review Comment:
    after using childStats.getRowCount(),  why discard original reasonable 
radio Math.pow(DEFAULT_AGGREGATE_EXPAND_RATIO, groupByCount - 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.

To unsubscribe, e-mail: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to