Skip to content
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

Merged
merged 2 commits into from
Mar 8, 2017
Merged

plan: forbid limit to push across selection. #2793

merged 2 commits into from
Mar 8, 2017

Conversation

hanfei1991
Copy link
Member

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 is Join(t,s)->TopN->Selection, it's wrong. After fixing it, the plan is Join(t,s)->Selection->TopN.
@shenli @coocood @zimulala PTAL

@hanfei1991 hanfei1991 added the type/bug The issue is confirmed as a bug. label Mar 7, 2017
@@ -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 {
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

@coocood coocood Mar 8, 2017

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]
Copy link
Member

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.

Copy link
Member Author

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.

@shenli
Copy link
Member

shenli commented Mar 8, 2017

LGTM

1 similar comment
@coocood
Copy link
Member

coocood commented Mar 8, 2017

LGTM

@coocood coocood merged commit 5a377ad into master Mar 8, 2017
@coocood coocood deleted the hanfei/bug branch March 8, 2017 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants