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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/StatsCalculator.java:
##########
@@ -1168,10 +1164,22 @@ public Statistics 
computeAssertNumRows(AssertNumRowsElement assertNumRowsElement
     }
 
     /**
-     * computeFilter
+     * Computes filter statistics without re-counting predicates already 
included in the scan row count.
      */
     public Statistics computeFilter(Filter filter, Statistics inputStats) {
-        return new FilterEstimation().estimate(filter.getPredicate(), 
inputStats);
+        // Use predicates already included in the scan row count only to 
restore column constraints;
+        // estimate the remaining predicates to avoid counting a partition 
predicate twice.
+        Set<Expression> appliedConjuncts = new 
LinkedHashSet<>(filter.getConjuncts());
+        appliedConjuncts.retainAll(inputStats.getConjunctsAppliedToRowCount());

Review Comment:
   列裁剪的 conjuncts 如果通过 stats 传递,那么会带来比较大的内存开销. stats 经常成为 nerieds 的内存瓶颈点. 
建议这里可以通过 filter 的 child 判断.如果 child 是 
OlapScan,那么通过scan.getPartitionPrunablePredicates()可以取得列裁剪 conjuncts. 
   如果在 memo 中, filter 的 child是 groupPlan, 然后查到 groupPlan 对应的 child group, 从 
child Group 的 logicalGroupExpression 可以得到 scan 



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