-
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
*: update extractor for tidb_index_usage and columns table #55263
Conversation
Hi @joechenrh. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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-sigs/prow repository. |
/ok-to-test |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #55263 +/- ##
================================================
+ Coverage 72.9185% 74.7655% +1.8470%
================================================
Files 1576 1576
Lines 440552 440707 +155
================================================
+ Hits 321244 329497 +8253
+ Misses 99560 90975 -8585
- Partials 19748 20235 +487
Flags with carried forward coverage won't be shown. Click here to find out more.
|
please add more detail on what you have done. and why you do that, if it's for optimize, what's test result? |
31fd724
to
cdb1080
Compare
9af7e87
to
73c7e27
Compare
|
||
idxs := extractor.ListIndexes(tbl) | ||
for _, idx := range idxs { | ||
row := make([]types.Datum, 0, 14) |
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.
Does it support the index_name filter?
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.
select ... from index_usage where table_schema = 'xxx' and index_name = 'yyy'
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.
Yes, it does.
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.
I see, it's inside the ListIndexes() function.
[LGTM Timeline notifier]Timeline:
|
if column.Hidden { | ||
continue | ||
} | ||
ord++ |
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.
should we move ord++ to L890, and let it increase the same pace with appending columns, otherwise, your ord and columns are not with the same length (max ord != len(columns)-1)?
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.
Ord is the ordinal positions of columns in tables, so it should increase for every non hidden column. Here is the logic before the modification:
tidb/pkg/executor/infoschema_reader.go
Lines 982 to 988 in 0e47f9a
i := 0 | |
ForColumnsTag: | |
for _, col := range tbl.Columns { | |
if col.Hidden { | |
continue | |
} | |
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.
i can get your code block, is this (max ord != len(columns)-1)?
reasonable ?
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.
@AilinKid Yes.
ORDINAL_POSITION
The position of the column within the table. ORDINAL_POSITION is necessary because you might want to say ORDER BY ORDINAL_POSITION
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.
Yes, since predicates may filter out some columns. And this value is the original position in the table.
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.
soga, okok
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AilinKid, tangenta, tiancaiamao 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 |
What problem does this PR solve?
Issue Number: ref #50305
Problem Summary:
What changed and how does it work?
Like #55144, this PR adds
InfoSchemaTableNameExtractor
to extract schemas, tables andlike
operators from predicates, and embed it into following extractors:InfoSchemaIndexesExtractor
, which is used forinfoschema.TableTiDBIndexUsage
ColumnsTableExtractor
, which is used forinfoschema.TableColumns
Check List
Tests
Create about 20w tables
Before and after:
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.