-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](CostBasedRewriteJob)restore StatementContext.rewrittenCteProducer in CostBasedRewriteJob #59517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
6e97d27 to
073c151
Compare
|
run buildall |
TPC-H: Total hot run time: 32774 ms |
TPC-DS: Total hot run time: 173200 ms |
ClickBench: Total hot run time: 26.79 s |
|
run buildall |
TPC-H: Total hot run time: 32270 ms |
TPC-DS: Total hot run time: 172742 ms |
ClickBench: Total hot run time: 27.06 s |
ef065c6 to
4438cb1
Compare
|
run buildall |
TPC-H: Total hot run time: 32582 ms |
TPC-DS: Total hot run time: 173742 ms |
ClickBench: Total hot run time: 27.28 s |
FE Regression Coverage ReportIncrement line coverage |
|
|
||
| private void restoreCteProducerMap(StatementContext context, Map<CTEId, LogicalPlan> currentCteProducers) { | ||
| context.getRewrittenCteProducer().clear(); | ||
| currentCteProducers.forEach(context.getRewrittenCteProducer()::put); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not put all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你的问题是 为什么不put all吗?这里就是put all
| } | ||
| // If the candidate applied cbo rule is better, replace the original plan with it. | ||
| if (appliedCboRuleCost.get().first.getValue() < skipCboRuleCost.get().first.getValue()) { | ||
| currentCtx.addPlanProcesses(applyCboRuleCtx.getPlanProcesses()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove addPlanProcesses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
假设plan1 被costBaseRule 改写为 plan2, 然后再被后续rule(不包含其他costBasedRule)改写为plan3
如果选中了costBaseRule的改写,那么退出costBaseRule后,我们应该从plan2继续改写。这里的plan process 记录的是 plan2 到plan3 的过程
| Map<CTEId, LogicalPlan> currentCteProducers = Maps.newHashMap(); | ||
| // cost based rewrite job may contaminate StatementContext.rewrittenCteProducer | ||
| // clone current rewrittenCteProducer, and restore it after getCost(.). | ||
| currentCtx.getStatementContext().getRewrittenCteProducer().forEach(currentCteProducers::put); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only process RewrittenCteProducer is enough? maybe we should process all cte related context just like what we do in ClearContextStatus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加了CteEnvironmentSnapshot, 恢复所有cte相关数据
|
run buildall |
TPC-H: Total hot run time: 31683 ms |
TPC-DS: Total hot run time: 172076 ms |
ClickBench: Total hot run time: 26.51 s |
What problem does this PR solve?
cost based rewrite job may contaminate StatementContext.rewrittenCteProducer
fix solution: clone current rewrittenCteProducer, and restore it after each call to getCost(...)
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)