englefly commented on code in PR #69028:
URL: https://github.com/apache/doris/pull/69028#discussion_r4311337857


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java:
##########
@@ -384,11 +384,19 @@ public Statistics visitLogicalFilter(LogicalFilter<? 
extends Plan> filter, Void
      * returns the sum of deltaRowCount for all selected partitions or for the 
table.
      */
     private long computeDeltaRowCount(OlapScan olapScan) {
+        OlapTable olapTable = olapScan.getTable();
+        // The delta rows are the rows loaded into the base index which the 
collected base index row count
+        // doesn't include yet. They are not the rows of an index which 
aggregates them: such an index has its
+        // own (usually much smaller) row count, so the delta only applies to 
a scan of an index which keeps
+        // one row per base row.
+        if (!TableStatsMeta.keepsOneRowPerBaseRow(olapTable, 
olapScan.getSelectedIndexId())) {
+            return 0;

Review Comment:
   Good catch, fixed in dc2d63c6987.
   
   `computeDeltaRowCount()` no longer checks `keepsOneRowPerBaseRow`. The value 
it returns is not the row count of the scanned index: it only feeds 
`Statistics.deltaRowCount`, which `FilterEstimation.estimate()` uses as the 
population to retry a zero estimate with, and stale column statistics are not 
index specific. The check stays in `TableStatsMeta#getRowCountWithDeltaRows()`, 
the only place where the delta is added to the collected row count of an index, 
and the javadoc of `computeDeltaRowCount()` now spells that split out so the 
check does not get re-added by accident.
   
   For the analyze/load/out-of-range-filter case, 
`StatsCalculatorTest#testDeltaRowCountIsReportedForNonRowPreservingIndex` 
asserts that a scan of a non-row-preserving index (an AGG rollup) over a record 
created by a load still reports the delta rows, i.e. the population the retry 
needs; the recovery itself is already covered by the existing 
`FilterEstimationTest#testDeltaRow`. Both compile and the new test passes 
locally.
   



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