LLLLLL302311 opened a new pull request, #66781:
URL: https://github.com/apache/doris/pull/66781
### What problem does this PR solve?
Problem Summary:
When a query contains many structurally-identical uncorrelated scalar
subqueries
that reference the same CTE (e.g. `(SELECT dt FROM deal_dt)` repeated
hundreds of
times), `SubqueryToApply` generated one `LogicalApply` per occurrence.
This blew up
the Nereids optimization search space and caused the planner to time out
(`Nereids cost too much time`), while these queries planned fine on the
legacy optimizer.
This PR groups reusable scalar subqueries within the same
`LogicalFilter`/`LogicalProject`
by `(cteId, cte name, projection, data type, nullable)` and builds a
single `Apply` for a
representative, letting the other occurrences reuse its output. Correlated
subqueries,
subqueries needing type coercion, `DISTINCT`/multi-column projections and
non-CTE
subqueries are excluded to preserve semantics.
### Release note
None
### Check List (For Author)
- Test
- [x] Unit Test
- [ ] Regression test
- [ ] Manual test
- [ ] No need to test or manual test.
- Behavior changed:
- [x] No.
- Does this need documentation?
- [x] No.
--
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]