-
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: forbid limit to push across selection. #2793
Conversation
@@ -855,6 +866,8 @@ func (p *Selection) convert2PhysicalPlanEnforce(prop *requiredProperty) (*physic | |||
if prop.limit != nil && len(prop.props) > 0 { | |||
if t, ok := info.p.(physicalDistSQLPlan); ok { | |||
t.addTopN(p.ctx, prop) | |||
} else if _, ok := info.p.(*Selection); !ok { |
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.
If the child info
is *Selection
, the Selection p
will be lost?
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.
If child is selection, it means the selection has been processed
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.
Oh, I remembered, the child has pulled the parent Selection down.
This design is anti-pattern.
np.SetChildren(childPlanInfo[0].p) | ||
count := uint64(float64(childPlanInfo[0].count) * selectionFactor) | ||
return &physicalPlanInfo{p: &np, cost: childPlanInfo[0].cost, count: count} | ||
return childPlanInfo[0] |
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.
Here the childPlanInfo
is actually not child, it is the selection itself?
Then the matchProperty
is not used as it is supposed to be.
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.
Yeah, in case of not on table, it's the selection itself.
LGTM |
1 similar comment
LGTM |
When the SQL is
Select * from t left join s on true where least(1,2,3,t1.a,t2.b) > 0 order by t2.a limit 10
, the old plan isJoin(t,s)->TopN->Selection
, it's wrong. After fixing it, the plan isJoin(t,s)->Selection->TopN
.@shenli @coocood @zimulala PTAL