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, executor: support batchget for range and list partition table #24856

Merged
merged 15 commits into from
May 28, 2021

Conversation

zhuo-zhi
Copy link
Contributor

@zhuo-zhi zhuo-zhi commented May 24, 2021

What problem does this PR solve?

Issue Number: close #24476, subitem of #24150

Problem Summary:

  • Support batchget for range and list partition table.

What is changed and how it works?

What's Changed:

  • Change BatchGet logic in the func TryFastPlan. Change executor logic for BatchGet accordingly.

How it Works:

  • Allow partition table other than hash partition to support BatchGet. Locate partition column in the func TryFastPlan, and locate partition table ID in the func Next in the executor accordingly.

Check List

Tests

  • Unit test

Side effects

  • N/A

Release note

  • planner, executor: support batchget for range and list partition table

@zhuo-zhi zhuo-zhi requested review from a team as code owners May 24, 2021 05:07
@zhuo-zhi zhuo-zhi requested review from XuHuaiyu and removed request for a team May 24, 2021 05:07
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 24, 2021
@github-actions github-actions bot added the sig/execution SIG execution label May 24, 2021
@qw4990 qw4990 requested review from rebelice, mjonss and qw4990 May 24, 2021 07:02
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 24, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2021
executor/batch_point_get.go Outdated Show resolved Hide resolved
@qw4990
Copy link
Contributor

qw4990 commented May 26, 2021

Almost LGTM, please address my small comments at your convenience @zhuo-zhi

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 26, 2021
Copy link
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

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

Some minor questions/suggestions

physID := getPhysID(e.tblInfo, idxVals[e.partPos].GetInt64())
physID, err := getPhysID(e.tblInfo, e.partExpr, idxVals[e.partPos].GetInt64())
if err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it continue instead of return err only because getPhysID() only returns an error when there is no matching partition? I.e. would use TableDual?

Copy link
Contributor Author

@zhuo-zhi zhuo-zhi May 26, 2021

Choose a reason for hiding this comment

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

As for BatchGet, if one data point in the where clause where col in (....) doesn't match any partition, we can just safely ignore it, and continue trying to fetch the next data point.

TableDual is not applicable here because we have already built our executor in buildBatchPointGet instead of buildTableDual.

unsigned := mysql.HasUnsignedFlag(col.GetType().Flag)
ranges := partitionExpr.ForRangePruning
length := len(ranges.LessThan)
partIdx := sort.Search(length, func(i int) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be used in several places (like getPartitionInfo in planner/core/point_get_plan.go), could it be moved to its own function? (i.e. searching and finding the range partition?)
Maybe refactor/break out the same code from locateRangePartition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, now it's more like an ad hoc solution. Maybe we can refactor our code after partition by range columns(...) and partition by list columns(...) GA.

return i, nil
}
}
panic("unique index must include all partition columns")
Copy link
Contributor

Choose a reason for hiding this comment

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

There are no hint in the name of the function or comment that it only applies to Unique indexes, could you add that to the comment above the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. It's updated in the new commit.

@mjonss
Copy link
Contributor

mjonss commented May 27, 2021

/lgtm (but I'm not yet in the reviewer list)

@qw4990 qw4990 added the sig/planner SIG: Planner label May 28, 2021
Copy link
Contributor

@rebelice rebelice 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-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qw4990
  • rebelice

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 28, 2021
@rebelice
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 0dd4e39

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 28, 2021
@qw4990
Copy link
Contributor

qw4990 commented May 28, 2021

/merge

@ti-chi-bot
Copy link
Member

@zhuo-zhi: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@sre-bot
Copy link
Contributor

sre-bot commented May 28, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dynamic partition pruning mode cannot use PointGet and BatchGet
6 participants