github-actions[bot] commented on code in PR #69850:
URL: https://github.com/apache/doris/pull/69850#discussion_r4414336957


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTableWrapper.java:
##########
@@ -190,6 +190,33 @@ public MaterializedIndex getBaseIndex() {
         return originTable.getBaseIndex();
     }
 
+    /**
+     * Row counts are derived from the partitions of the table, and this 
wrapper holds none of its
+     * own -- it only delegates partition lookups to the table it wraps. The 
inherited methods
+     * iterate the wrapper's private partition map, so every scan over a 
wrapper would be estimated
+     * at zero rows, which the statistics calculator raises to one; a reset 
read of a
+     * four-billion-row table would then look like a one-row build side to the 
optimizer.
+     *
+     * <p>Delegating answers the read with the table it is over: a reset read, 
and a snapshot read
+     * whose offsets already reached the end, see exactly that table's 
content, and a snapshot read
+     * of an older offset is bounded by it (the table only grows for the 
duplicate-key tables this
+     * wrapper serves in that way).
+     */
+    @Override
+    public long getRowCountForIndex(long indexId, boolean strict) {
+        return originTable.getRowCountForIndex(indexId, strict);
+    }
+
+    @Override
+    public long getRowCountForPartitionIndex(long partitionId, long indexId, 
boolean strict) {
+        return originTable.getRowCountForPartitionIndex(partitionId, indexId, 
strict);
+    }
+
+    @Override
+    public int getPartitionNum() {

Review Comment:
   [P2] Preserve the changelog wrapper's unknown cardinality for 
partition-pruned reads. With `PARTITION (p1, p2)` on a direct `@incr` scan (or 
an incremental stream plan with a strict subset), this new `getPartitionNum()` 
makes `StatsCalculator` enter its selected-partition fallback. Both 
`getRowCountForPartitionIndex` calls return `UNKNOWN_ROW_COUNT`, so the 
fallback fabricates one row per selected partition; a range can contain no 
change rows, and the estimate now grows with the number of selected partitions. 
Before this override the wrapper partition count was zero, the branch was 
skipped, and the estimate stayed at the existing one-row unknown fallback. Keep 
changelog scans on the unknown path (or bypass this partition fallback) and add 
a multi-partition incremental EXPLAIN regression.



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