feiniaofeiafei opened a new pull request, #67067:
URL: https://github.com/apache/doris/pull/67067
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: None
Problem Summary:
The effectiveness of eager aggregation pushdown depends on the shape of the
input join tree. When the initial join order is suboptimal, aggregation may be
pushed down at an ineffective position or miss a beneficial pushdown
opportunity.
This PR introduces a statistics-based greedy join reorder before eager
aggregation. It extracts eligible inner/cross join clusters, searches for a
better join order, rebuilds join predicates, and preserves the original output
slots and order. The reordered plan is retained only when eager aggregation is
successfully pushed down; otherwise, the original plan is restored.
The rewrite includes safety fallbacks for invalid predicate mappings,
excessive atom counts, increased cross joins, invalid statistics, hints,
mark/ASOF joins, and volatile expressions. Candidate selection is deterministic
when costs are equal, and column pruning is applied after reordering. A session
variable, `disable_join_reorder_before_eager_agg`, is provided as a fallback
switch, and DEBUG logging records the reorder elapsed time and whether the plan
changed.
### Release note
Improve eager aggregation planning by reordering eligible joins before
aggregate pushdown.
### Check List (For Author)
- Test
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
- Behavior changed:
- [ ] No.
- [x] Yes.
- Eligible joins may be reordered before eager aggregation pushdown.
Query result semantics remain unchanged, and the optimization can be disabled
using `disable_join_reorder_before_eager_agg`.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]