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

executor: enhance global index #41197

Merged

Conversation

L-maple
Copy link
Contributor

@L-maple L-maple commented Feb 8, 2023

What problem does this PR solve?

Issue Number: close #40497
Issue Number: close #21732
Issue Number: close #40149

Note: PR #22478 doest not solve #40149 actually, so I list it here.

Problem Summary:

What is changed and how it works?

  • filter out the selected partitions in IndexLookUpExecutor when global index query specifies partitions.
  • only dynamic mode and global stats is ready, we can use the global index. Otherwise ignore it, as PartitionUnionAll logical plan not suitable for global index.
  • when drop global index's regions(drop table/index), we should specify the correct key prefix, like t{tableID}_i{indexID}.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 8, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Defined2014
  • mjonss

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 submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Feb 8, 2023
@ti-chi-bot
Copy link
Member

Hi @L-maple. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 kubernetes/test-infra repository.

@L-maple
Copy link
Contributor Author

L-maple commented Feb 8, 2023

/label severity-moderate

@ti-chi-bot
Copy link
Member

@L-maple: The label(s) severity-moderate cannot be applied. These labels are supported: fuzz/sqlancer, challenge-program, compatibility-breaker, first-time-contributor, contribution, require-LGT3, good first issue, correctness, duplicate, proposal, security, needs-more-info, needs-cherry-pick-release-4.0, needs-cherry-pick-release-5.0, needs-cherry-pick-release-5.1, needs-cherry-pick-release-5.2, needs-cherry-pick-release-5.3, needs-cherry-pick-release-5.4, needs-cherry-pick-release-6.0, needs-cherry-pick-release-6.1, needs-cherry-pick-release-6.2, needs-cherry-pick-release-6.3, needs-cherry-pick-release-6.4, needs-cherry-pick-release-6.5, affects-4.0, affects-5.0, affects-5.1, affects-5.2, affects-5.3, affects-5.4, affects-6.0, affects-6.1, affects-6.2, affects-6.3, affects-6.4, affects-6.5, may-affects-4.0, may-affects-5.0, may-affects-5.1, may-affects-5.2, may-affects-5.3, may-affects-5.4, may-affects-6.0, may-affects-6.1, may-affects-6.2, may-affects-6.3, may-affects-6.4, may-affects-6.5.

In response to this:

/label severity-moderate

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.

@L-maple
Copy link
Contributor Author

L-maple commented Feb 8, 2023

/label severity/moderate

@ti-chi-bot
Copy link
Member

@L-maple: The label(s) severity/moderate cannot be applied. These labels are supported: fuzz/sqlancer, challenge-program, compatibility-breaker, first-time-contributor, contribution, require-LGT3, good first issue, correctness, duplicate, proposal, security, needs-more-info, needs-cherry-pick-release-4.0, needs-cherry-pick-release-5.0, needs-cherry-pick-release-5.1, needs-cherry-pick-release-5.2, needs-cherry-pick-release-5.3, needs-cherry-pick-release-5.4, needs-cherry-pick-release-6.0, needs-cherry-pick-release-6.1, needs-cherry-pick-release-6.2, needs-cherry-pick-release-6.3, needs-cherry-pick-release-6.4, needs-cherry-pick-release-6.5, affects-4.0, affects-5.0, affects-5.1, affects-5.2, affects-5.3, affects-5.4, affects-6.0, affects-6.1, affects-6.2, affects-6.3, affects-6.4, affects-6.5, may-affects-4.0, may-affects-5.0, may-affects-5.1, may-affects-5.2, may-affects-5.3, may-affects-5.4, may-affects-6.0, may-affects-6.1, may-affects-6.2, may-affects-6.3, may-affects-6.4, may-affects-6.5.

In response to this:

/label severity/moderate

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.

@L-maple L-maple force-pushed the feature/enhance_global_index_master branch from ed7b0ce to 85938c4 Compare February 8, 2023 11:37
@L-maple
Copy link
Contributor Author

L-maple commented Feb 8, 2023

/cc @tiancaiamao @mjonss

@L-maple
Copy link
Contributor Author

L-maple commented Feb 8, 2023

/assign @tiancaiamao

@L-maple
Copy link
Contributor Author

L-maple commented Feb 8, 2023

/cc @xuyifangreeneyes

@L-maple L-maple changed the title executor: enhance global index fix(executor): enhance global index Feb 8, 2023
@L-maple
Copy link
Contributor Author

L-maple commented Feb 8, 2023

/auto-cc

@L-maple L-maple changed the title fix(executor): enhance global index executor: enhance global index Feb 8, 2023
@L-maple L-maple force-pushed the feature/enhance_global_index_master branch from 85938c4 to 05b6563 Compare February 9, 2023 03:09
@L-maple L-maple mentioned this pull request Feb 10, 2023
12 tasks
@L-maple
Copy link
Contributor Author

L-maple commented Feb 10, 2023

/cc @bb7133

@ti-chi-bot ti-chi-bot requested a review from bb7133 February 10, 2023 06:36
@mjonss
Copy link
Contributor

mjonss commented Feb 15, 2023

/retest

ddl/index.go Outdated Show resolved Hide resolved
@L-maple L-maple force-pushed the feature/enhance_global_index_master branch from 05b6563 to 3a5dd69 Compare February 15, 2023 11:13
@L-maple
Copy link
Contributor Author

L-maple commented Feb 16, 2023

@L-maple please check if TestIngestMVIndexOnPartitionTable and TestIssue34228 is affected by this PR?

Maybe TestIngestMVIndexOnPartitionTable has no relation with my PR, which is always wrong.

@L-maple L-maple force-pushed the feature/enhance_global_index_master branch 3 times, most recently from 9772e56 to 6b383c9 Compare February 16, 2023 12:08
@Defined2014
Copy link
Contributor

/retest-required

@L-maple L-maple force-pushed the feature/enhance_global_index_master branch from 6b383c9 to c808d37 Compare February 17, 2023 03:13
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 17, 2023
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 17, 2023
@L-maple L-maple requested a review from mjonss February 17, 2023 08:45
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.

LGTM, just some minor questions. Great work!

@@ -97,7 +97,7 @@ func expectedDeleteRangeCnt(ctx delRangeCntCtx, job *model.Job) (int, error) {
if err := job.DecodeArgs(&startKey, &physicalTableIDs, &ruleIDs); err != nil {
return 0, errors.Trace(err)
}
return mathutil.Max(len(physicalTableIDs), 1), nil
return mathutil.Max(len(physicalTableIDs)+1, 1), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why Max(x+1, 1) if x >= 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For drop table ddl the [t{tableID}_, t{tableID+1}) range is deleted in finishDDLJob, as logical table may contain global index.

Copy link
Contributor

@Defined2014 Defined2014 Feb 21, 2023

Choose a reason for hiding this comment

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

I don't think the max function is needed anymore here. Since len(xx) is always >= 0, the return value of the max function is always equal to len(physicalTableIDs)+1. @L-maple

Suggested change
return mathutil.Max(len(physicalTableIDs)+1, 1), nil
return len(physicalTableIDs)+1, nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Defined2014 resolved, thanks.

executor/partition_table_test.go Show resolved Hide resolved
@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 Feb 17, 2023
@mjonss
Copy link
Contributor

mjonss commented Feb 17, 2023

@L-maple Please ping me when you want to merge this into pingcap/tidb/master.

@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/retest-required

@L-maple L-maple requested a review from mjonss February 20, 2023 09:17
@L-maple
Copy link
Contributor Author

L-maple commented Feb 20, 2023

@L-maple Please ping me when you want to merge this into pingcap/tidb/master.

@mjonss This PR can be merged, thanks for your advice above. There are still some bugs and nice features for global index. I will contribute more code for global index.

@L-maple L-maple force-pushed the feature/enhance_global_index_master branch from c808d37 to 7255cc1 Compare February 21, 2023 03:14
@Defined2014
Copy link
Contributor

@L-maple Please ping me when you want to merge this into pingcap/tidb/master.

@mjonss This PR can be merged, thanks for your advice above. There are still some bugs and nice features for global index. I will contribute more code for global index.

Let's wait till friday, if there is no news from mjonss, I will merge this PR. cc @mjonss

@mjonss
Copy link
Contributor

mjonss commented Feb 21, 2023

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 7255cc1

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 21, 2023
@ti-chi-bot ti-chi-bot merged commit 5cbf6eb into pingcap:master Feb 21, 2023
@L-maple
Copy link
Contributor Author

L-maple commented Feb 23, 2023

@mjonss Hi, mjonss! I just found the global index proposal was proposed in 2020.

  1. Why it is delayed so long?
  2. Is there any future plans for how to improve it in TiDB teams, and how long the global index will be a GA feature?
  3. Could you give me some advice or prepared plans for improving the global index?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 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
6 participants