-
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: avoid double scan for index prefix col is (not) null #38555
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. |
/run-mysql-test tidb-test=pr/1999 |
1 similar comment
/run-mysql-test tidb-test=pr/1999 |
/hold |
/unhold |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 42778ff
|
/hold |
/unhold |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 5ecc79e
|
/run-mysql-test tidb-test=pr/1999 |
TiDB MergeCI notify🔴 Bad News! New failing [3] after this pr merged.
|
} | ||
isFullLength := c.isFullLengthColumn() | ||
if scalar.FuncName.L == ast.NE { | ||
return isFullLength, !isFullLength |
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.
just curious, should this be theoretical possible
a(2) != xxx
[-min, xxx(prefix)0000 ), [xx(x+1)(prefix)FFFF, +max]
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.
It is theoretical possible for some types and collations. But there may be some problems like #21145 (comment) for some string types and collations.
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.
Rest LGTM
What problem does this PR solve?
Issue Number: ref #21145
Problem Summary:
We want to avoid double scan when using index
idx2
for the query.What is changed and how it works?
tidb_opt_prefix_index_single_scan
. If the switch is on, do the following two optimizations.IsNull
doesn't need to be reserved even if the index column is prefix column.path.IsSingleScan
, the old way is to check whetherds.schema.Columns
is subset of index columns which are not prefix column. While the new way is to check two things:a. whether
ds.colsRequiringFullLen
is subset of index columns which are not prefix column.b. whether
ds.allConds
is covered by the index.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.