yujun777 commented on code in PR #71034:
URL: https://github.com/apache/doris/pull/71034#discussion_r4751427928
##########
fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java:
##########
@@ -827,6 +830,27 @@ private ExprSubstitutionMap createPointQueryProjectionSmap(
return substitutionMap;
}
+ @Override
+ protected PlanNode findFirstMatching(Predicate<? super TreeNode<PlanNode>>
predicate) {
+ // Exchanges for different CTE consumers can share the same producer
root.
+ Set<PlanNode> visited = Sets.newIdentityHashSet();
+ Deque<PlanNode> pending = new ArrayDeque<>();
+ pending.push(this);
+ while (!pending.isEmpty()) {
+ PlanNode node = pending.pop();
+ if (!visited.add(node)) {
+ continue;
+ }
+ if (predicate.test(node)) {
+ return node;
+ }
+ for (int i = node.children.size() - 1; i >= 0; i--) {
Review Comment:
**[P2] Preserve early exit on wide plan nodes**
This loop pushes every child before checking the first one. For a wide
`UNION ALL` with a null-aware anti join near the top of its first branch, the
previous traversal did constant work per search. This traversal does O(N) stack
work for N children. During local shuffle planning, each `OlapScanNode` in the
same fragment can call `useSerialSource()` and repeat the search from the
fragment root, so with O(N) such scans the anti-join checks can go from O(N) to
O(N²).
Could we keep a stack of child iterators and pull one child at a time? That
keeps identity deduplication and left-to-right DFS while leaving later siblings
untouched on an early match. The current test counts predicate calls. A
regression test can also count child reads when the first child matches.
--
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]