-
Notifications
You must be signed in to change notification settings - Fork 198
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
sync-diff-inspector: add sql-hint-use-index
in config for automatically apply hint in check SQL
#837
Conversation
/retest |
1 similar comment
/retest |
/release-note-none |
/retest |
1 similar comment
/retest |
/cc @kennytm |
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
require.Equal(t, len(node.ChunkRange.IndexColumnNames), len(testColNames)) | ||
for i, c := range testColNames { | ||
require.Equal(t, c, node.ChunkRange.IndexColumnNames[i]) | ||
} |
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.
require.Equal(t, len(node.ChunkRange.IndexColumnNames), len(testColNames)) | |
for i, c := range testColNames { | |
require.Equal(t, c, node.ChunkRange.IndexColumnNames[i]) | |
} | |
require.Equal(t, node.ChunkRange.IndexColumnNames, testColNames) |
require.Equal
uses reflect.DeepEqual
which supports slices.
sync_diff_inspector/source/tidb.go
Outdated
indexHint = fmt.Sprintf("/*+ USE_INDEX(`%s`.`%s`, `%s`) */", | ||
matchSource.OriginSchema, | ||
matchSource.OriginTable, | ||
index.Name.L, | ||
) |
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.
indexHint = fmt.Sprintf("/*+ USE_INDEX(`%s`.`%s`, `%s`) */", | |
matchSource.OriginSchema, | |
matchSource.OriginTable, | |
index.Name.L, | |
) | |
indexHint = fmt.Sprintf("/*+ USE_INDEX(%s, %s) */", | |
dbutil.TableName(matchSource.OriginSchema, matchSource.OriginTable), | |
dbutil.ColumnName(index.Name.O), | |
) |
(yeah it is not a column but whatever)
sql-hint-use-index
in config for automatically apply hint in check SQL
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kennytm The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/retest |
What problem does this PR solve?
Issue Number: close #836
Add hint
/*+ USE_INDEX(dbName.tblName, indexName) */
to force index scan in checksum SQL. Note this index hint is only applied on TiDB source.How to use?
What is changed and how it works?
In each chunk, we will store the column names of the index used to split chunks. These column names will be used to match exact index name to build the index hint.
The reason we store column names rather than store index name directly is to avoid different index names between upstream and downstream.
For example:
t1(id int, col1 int, unique index i1(id, col1))
t1(id int, col1 int, unique index i2(id, col1))
Check List
Tests
Code changes
Side effects
Related changes