-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
plan: merge continuous selections and delete surely true expressions #24214
Conversation
" └─HashJoin 9990.00 cop[tiflash] inner join, equal:[eq(test.ts.col_varchar_64, test.ts.col_varchar_key)]", | ||
" ├─ExchangeReceiver(Build) 7992.00 cop[tiflash] ", | ||
" │ └─ExchangeSender 7992.00 cop[tiflash] ExchangeType: Broadcast", | ||
" │ └─Selection 7992.00 cop[tiflash] 1, not(isnull(test.ts.col_varchar_key))", |
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.
otherwise, there are two continuous selections.
/run-check_dev_2 |
/run-unit-test |
/run-monitor-test |
/run-monitor-test |
Visit the grafana server at: http://172.16.5.5:32348, it will last for 5 hours |
@@ -156,9 +157,34 @@ func DoOptimize(ctx context.Context, sctx sessionctx.Context, flag uint64, logic | |||
return finalPlan, cost, nil | |||
} | |||
|
|||
// mergeContinuousSelections merge continuous selections which may occur after changing plans. | |||
func mergeContinuousSelections(p PhysicalPlan) { |
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 we need this in the physical phase?
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.
Taking the issue as an example, a projection is eleminated in the postOptimize, then two selections become continuous, so we should merge at the last of postOptimize.
I'm a little curious about the The |
For the case in the issue, the selection(true) comes from pushing down predicates in projection. Adding |
@@ -73,6 +79,8 @@ func splitSetGetVarFunc(filters []expression.Expression) ([]expression.Expressio | |||
|
|||
// PredicatePushDown implements LogicalPlan PredicatePushDown interface. | |||
func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan) { | |||
predicates = DeleteTrueExprs(p, predicates) |
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.
It's a little redundant to remove it every time by checking the predicates passed down.
We could only do it for selection and join since they are generated the ones to be passed to their children
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.
en, we delete that in func (p *LogicalUnionScan) PredicatePushDown
, but that in func (ds *DataSource) PredicatePushDown(
is needed, because PropagateConstant may introduce some surely true expressions.
/run-common-test |
/run-common-test tidb-test=pr/1187 |
/run-common-test --tidb-test=pr/1187 |
/run-integration-common-test --tidb-test=pr/1187 |
/run-integration-common-test --tidb-test=pr/1187 |
/run-common-test --tidb-test=pr/1187 |
/run-integration-common-test --tidb-test=pr/1187 |
/run-integration-common-test --tidb-test=pr/1187 |
/run-common-test --tidb-test=pr/1187 |
/run-integration-common-test --tidb-test=pr/1187 |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: c3003a5
|
/run-integration-common-test --tidb-test=pr/1187 |
/run-common-test --tidb-test=pr/1187 |
/run-integration-ddl-test |
/run-integration-common-test --tidb-test=pr/1187 |
/run-integration-common-test --tidb-test=pr/1187 |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-5.0 in PR #24533 |
What problem does this PR solve?
Issue Number: close #24213, pingcap/tiflash#1731
Problem Summary:
What is changed and how it works?
Proposal: xxx
What's Changed:
some selections may become continuous after some optimizations like eliminating projections. Continuous selections are not supported in TiFlash. From the performance perspective, it is better to merge continuous selections to reduce compution.
on the other hand, we delete surely true expressions during pushing down expressions.
How it Works:
do the post optimization to merge continuous selections, and delete surely true expressions.
Related changes
Check List
Tests
Side effects
Release note