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: use point get plan for UPDATE statement #7586

Merged
merged 6 commits into from
Sep 3, 2018

Conversation

coocood
Copy link
Member

@coocood coocood commented Sep 3, 2018

What problem does this PR solve?

Optmize single row update statement.

What is changed and how it works?

Use point-get plan for UPDATE statement with a unique key equal condition.

Check List

Tests

  • Unit test (existing tests already covered)

Related changes

  • Need to be included in the release note

@coocood
Copy link
Member Author

coocood commented Sep 3, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Sep 3, 2018

@jackysp @tiancaiamao PTAL

@zz-jason
Copy link
Member

zz-jason commented Sep 3, 2018

any benchmark results?

@coocood
Copy link
Member Author

coocood commented Sep 3, 2018

@zz-jason will be provided later.

@coocood
Copy link
Member Author

coocood commented Sep 3, 2018

/run-unit-test

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -95,6 +95,7 @@ func (*testSuite) TestSchemaValidator(c *C) {
c.Assert(valid, Equals, ResultUnknown)

close(exit)
time.Sleep(time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait for the goroutine to quit to pass leak test.

if fastSelect == nil {
return nil
}
checkFastPlanPrivilege(ctx, fastSelect, mysql.SelectPriv, mysql.UpdatePriv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the result?

@coocood
Copy link
Member Author

coocood commented Sep 3, 2018

@zz-jason
benchmarked sysbench update-non-index in a single TiKV cluster, the QPS doesn't change because the bottleneck is TiKV, the CPU utilization of tidb-server has dropped 17%.

@coocood
Copy link
Member Author

coocood commented Sep 3, 2018

/run-all-tests

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coocood coocood added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 3, 2018
@ngaut ngaut merged commit 418cdf2 into pingcap:master Sep 3, 2018
tp := types.NewFieldType(mysql.TypeUnspecified)
types.DefaultParamTypeForValue(v.GetValue(), tp)
value := &Constant{Value: v.Datum, RetType: tp}
sr.push(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused about this newly added modification. Since we convert ParamMakerExpr to Constant here, what if we execute the prepared statement with another parameter? will it still use the previous constant instead of the parameter we provide?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We rebuild the plan for every execution.
And each execution updates the value in the ParamMakerExpr.

@coocood coocood deleted the point-get-for-update branch September 4, 2018 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants