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

planner/core: fix partition selection on PointGet/BatchPointGet #19146

Merged
merged 2 commits into from
Aug 12, 2020

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Aug 12, 2020

What problem does this PR solve?

Issue Number: close #19141

Problem Summary:

PointGet/BatchPointGet on the hash partition table does not take partition selection grammar into consideration.

What is changed and how it works?

What's Changed:

How it Works:

  • consider partition selection for PointGet
  • do not use BatchPointGet when partition selection exists

Related changes

This PR is on the 4.0 branch, I will file another one to fix the master.

Check List

Tests

  • Unit test

Release note

  • Fix bug PointGet and BatchPointGet do not consider partition selection grammar and get incorrect results.

@tiancaiamao tiancaiamao added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Aug 12, 2020
@tiancaiamao tiancaiamao requested review from imtbkcat and coocood and removed request for imtbkcat August 12, 2020 05:19
@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @imtbkcat

@coocood
Copy link
Member

coocood commented Aug 12, 2020

LGTM

@ti-srebot
Copy link
Contributor

@coocood,Thanks for your review. However, LGTM is restricted to Reviewers or higher roles.See the corresponding SIG page for more information. Related SIGs: planner(slack).

Copy link

@imtbkcat imtbkcat left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 12, 2020
@@ -749,6 +764,16 @@ func tryPointGetPlan(ctx sessionctx.Context, selStmt *ast.SelectStmt) *PointGetP
return nil
}

func partitionNameInSet(name model.CIStr, pnames []model.CIStr) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a performance issue when the partition count is large, For example: 65535.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This name slice is not all the partitions of a table.
It's just the selected ones:

select * from t partition (p0,p1,p2) ...

A sane person would not write a SQL like this:

select * from t partition (p0,p1,p2....p65535) ...

Copy link
Contributor

@SunRunAway SunRunAway left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -429,3 +429,22 @@ func (s *testPointGetSuite) TestBatchPointGetPartition(c *C) {
tk.MustExec("delete from t where (a,b) in ((1,1),(2,2),(3,3),(4,4))")
tk.MustQuery("select * from t where (a, b) in ((1, 1), (2, 2), (3, 3), (4, 4))").Check(testkit.Rows())
}

func (s *testPointGetSuite) TestIssue19141(c *C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this case be ported back to master branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Aug 12, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Aug 12, 2020
@SunRunAway
Copy link
Contributor

/merge

@ti-srebot
Copy link
Contributor

Sorry @SunRunAway, you don't have permission to trigger auto merge event on this branch.
The version releasement is in progress.

@jebter
Copy link

jebter commented Aug 12, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 12, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 1483de3 into pingcap:release-4.0 Aug 12, 2020
tiancaiamao added a commit to tiancaiamao/tidb that referenced this pull request Aug 12, 2020
…cap#19146)

* planner/core: fix partition selection on PointGet/BatchPointGet

* make golint happy
@tiancaiamao tiancaiamao deleted the point-get-partition-4.0 branch August 13, 2020 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants