-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
planner: fix can't find proper physical plan caused by virtual column #41132
Merged
ti-chi-bot
merged 20 commits into
pingcap:master
from
AilinKid:fix-bad-plan-caused-by-virtual-col
Feb 9, 2023
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a1f2eb1
fix can't find proper physical plan caused by virtual column
AilinKid 37ac1b7
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid ced97f0
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid 868d58f
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid f35b9d3
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid 8124abe
Update planner/core/exhaust_physical_plans.go
AilinKid e16ee0e
address comment
AilinKid 6687ab4
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid 6dc2635
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid 65ca5d2
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
ti-chi-bot 23b3e98
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid 2fdcb58
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid ff85247
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
ti-chi-bot 4712372
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
ti-chi-bot 3b06609
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
ti-chi-bot a280913
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
ti-chi-bot 41e473b
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid 1905d27
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
AilinKid b93491a
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
fzzf678 d5ebe2b
Merge branch 'master' into fix-bad-plan-caused-by-virtual-col
ti-chi-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2790,7 +2790,9 @@ func (la *LogicalAggregation) getStreamAggs(prop *property.PhysicalProperty) []P | |
if la.HasDistinct() { | ||
// TODO: remove AllowDistinctAggPushDown after the cost estimation of distinct pushdown is implemented. | ||
// If AllowDistinctAggPushDown is set to true, we should not consider RootTask. | ||
if !la.ctx.GetSessionVars().AllowDistinctAggPushDown { | ||
if !la.ctx.GetSessionVars().AllowDistinctAggPushDown || !la.canPushToCop(kv.TiKV) { | ||
// if variable doesn't allow DistinctAggPushDown, just produce root task type. | ||
// if variable does allow DistinctAggPushDown, but OP itself can't be pushed down to tikv, just produce root task type. | ||
taskTypes = []property.TaskType{property.RootTaskType} | ||
} else if !la.distinctArgsMeetsProperty() { | ||
continue | ||
|
@@ -2942,6 +2944,15 @@ func (la *LogicalAggregation) tryToGetMppHashAggs(prop *property.PhysicalPropert | |
return | ||
} | ||
|
||
// getHashAggs will generate some kinds of taskType here, which finally converted to different task plan. | ||
// when deciding whether to add a kind of taskType, there is a rule here. [Not is Not, Yes is not Sure] | ||
// eg: which means | ||
// | ||
// 1: when you find something here that block hashAgg to be pushed down to XXX, just skip adding the XXXTaskType. | ||
// 2: when you find nothing here to block hashAgg to be pushed down to XXX, just add the XXXTaskType here. | ||
// for 2, the final result for this physical operator enumeration is chosen or rejected is according to more factors later (hint/variable/partition/virtual-col/cost) | ||
// | ||
// That is to say, the non-complete positive judgement of canPushDownToMPP/canPushDownToTiFlash/canPushDownToTiKV is not that for sure here. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean: "canPushDownToMPP/canPushDownToTiFlash/canPushDownToTiKV might be false positive" |
||
func (la *LogicalAggregation) getHashAggs(prop *property.PhysicalProperty) []PhysicalPlan { | ||
if !prop.IsSortItemEmpty() { | ||
return nil | ||
|
@@ -2955,7 +2966,9 @@ func (la *LogicalAggregation) getHashAggs(prop *property.PhysicalProperty) []Phy | |
canPushDownToMPP := canPushDownToTiFlash && la.ctx.GetSessionVars().IsMPPAllowed() && la.checkCanPushDownToMPP() | ||
if la.HasDistinct() { | ||
// TODO: remove after the cost estimation of distinct pushdown is implemented. | ||
if !la.ctx.GetSessionVars().AllowDistinctAggPushDown { | ||
if !la.ctx.GetSessionVars().AllowDistinctAggPushDown || !la.canPushToCop(kv.TiKV) { | ||
// if variable doesn't allow DistinctAggPushDown, just produce root task type. | ||
// if variable does allow DistinctAggPushDown, but OP itself can't be pushed down to tikv, just produce root task type. | ||
taskTypes = []property.TaskType{property.RootTaskType} | ||
} | ||
} else if !la.aggHints.preferAggToCop { | ||
|
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.
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.
This rule seems a bit hard to understand 😆