-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: add heuristic rules for index selection #26304
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/sig planner |
/cc @winoros |
77cce9f
to
3e73ab9
Compare
@xuyifangreeneyes: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function DataSource.DeriveStats
is too huge. It's better to split it into multiple functions, and then put all logic about heuristic rules in one of them?
Co-authored-by: Yuanjia Zhang <[email protected]>
tk.MustExec("drop table if exists t1, t2") | ||
tk.MustExec("create table t1(a int, b int, c int, d int, e int, f int, g int, primary key (a), unique key c_d_e (c, d, e), unique key f (f), unique key f_g (f, g), key g (g))") | ||
tk.MustExec("create table t2(a int, b int, c int, d int, unique index idx_a (a), unique index idx_b_c (b, c), unique index idx_b_c_a_d (b, c, a, d))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some cases about ClusteredIndex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 1eddf71
|
@xuyifangreeneyes: 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. |
1 similar comment
@xuyifangreeneyes: 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. |
What problem does this PR solve?
close #26319
What is changed and how it works?
What's Changed & How it Works:
In
(*DataSource).DeriveStats
, we try heuristic rules to select the path from possible access paths. Once some path matches heuristics, we remove other paths fromds.possibleAccessPaths
, let the selected path remain and add a NOTE level warning to indicate the path matches heuristics.uniqueIdxsWithDoubleScan
. For the one inuniqueIdxsWithDoubleScan
with the minimal number of ranges, we record it asuniqueBest
.singleScanIdxs
. For each index insingleScanIdxs
, if it is better than some index inuniqueIdxsWithDoubleScan
(there is a subset relation between twoaccessCondsColSet
), we call it a refined index. We select the refined index with the minimal number of ranges asrefinedBest
.uniqueBest
andrefinedBest
and choose the better one.Check List
Tests
Side effects
Documentation
Release note