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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to