xzj7019 opened a new pull request, #19288: URL: https://github.com/apache/doris/pull/19288
# Proposed changes Support subquery combination optimization. ## Problem summary This pr supports subquery combination optimization. This kind of combination can help to identify and eliminate similar subqueries which have containment relationship and have a performance gain. Currently only support exist-notexists combination type, i.e, if we find a exists subquery is contained by a notexists subquery, the not exists one can be eliminated and move the excepted expressions, such as filter conditions into exists subquery with additional having sum(case when excepted_filters then 1 else 0) = 0 constraint. Describe your changes. This pr adds a subquery combine rule in analyze stage, since the subquery removing action should be identified before SubqueryToApply. This rule will check all the preconditions the optimization will be taken. A UnCorrelatedApplyHavingProjectFilter rewrite rule will be taken after subquery transformed, and a special having expression will be set into apply and finally into semi-join with a similar way. At last, a general designed semi-to-inner rewrite rule is added to identify this having expression, which marked this semi-to-inner will use inner + gby pattern, and the having expression will follow this generated gby. Note that subquery combination is designed for general purpose but currently only support exists-notexists, the rest types, such as exists-exists, etc, will be supported in the future. So as the semi-to-inner rule, currently only support inner + gby pattern under some special cases, but the rest common types, such as pure inner and gby inner pattern will be supported in the future. ## Checklist(Required) * [ ] Does it affect the original behavior * [ ] Has unit tests been added * [ ] Has document been added or modified * [ ] Does it need to update dependencies * [ ] Is this PR support rollback (If NO, please explain WHY) ## Further comments If this is a relatively large or complex change, kick off the discussion at [d...@doris.apache.org](mailto:d...@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc... -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org