Conversation
…ategy (apache#60601) ### What problem does this PR solve? Previously, CTE inlining was controlled by a simple boolean flag (enableCboCteInline), which either fully enabled or disabled CBO-based CTE inline comparison. This was too coarse-grained — in some cases, full CBO comparison is unnecessary overhead, while in others (e.g., TPC-DS query74), a UNION ALL CTE can be selectively inlined when consumer filters eliminate entire union branches, producing a clearly better plan without needing full cost comparison. This PR replaces the boolean enableCboCteInline with an integer CteInlineMode that supports three modes: - mode < 0: Disable CTE inlining entirely. - mode = 0: Selective inline — only inline CTEs whose body contains a UNION ALL, and only when consumer-side filters can eliminate some union branches (i.e., produce EmptyRelation after filter pushdown). When this condition is met, the inlined plan is directly selected without CBO cost comparison. - mode >= 1 (default): Full CBO comparison — both materialized and inlined alternatives are added to the Memo for cost-based selection (original behavior).
…CTE inline Regenerated regression-test/data/shape_check baselines with -forceGenOut on branch-4.2 + apache#60601: tpcds_sf100/{shape,no_stats_shape,noStatsRfPrune,rf_prune}, tpcds_sf1000/{shape,hint}, tpcds_sf10t_orc/shape and tpcds_sf1000_constraints/shape for queries 4, 11 and 74.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #60601 to branch-4.2
Enhancement Support multi-mode CTE inline strategy
Replaces the boolean enableCboCteInline behaviour with an integer
cte_inline_mode(<0 disable, 0 selective inline, >=1 full CBO comparison, default 0).
Adaptations for branch-4.2: the new session variable uses branch-4.2's
@VariableMgr.VarAttrannotation, and the shape_check baselines for tpcds queries4/11/74 were regenerated with -forceGenOut on branch-4.2 (tpcDS/TPC-H plan shapes
differ from master).
Tests: new suites test_cte_multiuse_no_union_not_inline and
test_cte_nondeterministic_not_inline pass, plus distinct_agg_strategy_selector and
the regenerated shape_check suites (12+6+3+1 suites, 0 failures).