-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: add extractor for cluster_tidb_index_usage #55416
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #55416 +/- ##
================================================
+ Coverage 74.8640% 75.0836% +0.2196%
================================================
Files 1576 1578 +2
Lines 365691 443829 +78138
================================================
+ Hits 273771 333243 +59472
- Misses 72108 90462 +18354
- Partials 19812 20124 +312
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/ok-to-test |
pkg/executor/infoschema_reader.go
Outdated
@@ -3691,7 +3691,7 @@ func (e *memtableRetriever) setDataForClusterIndexUsage(ctx context.Context, sct | |||
dom := domain.GetDomain(sctx) | |||
rows := make([][]types.Datum, 0, 100) | |||
checker := privilege.GetPrivilegeManager(sctx) | |||
extractor, ok := e.extractor.(*plannercore.InfoSchemaBaseExtractor) | |||
extractor, ok := e.extractor.(*plannercore.InfoSchemaIndexUsageExtractor) |
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.
Maybe add a method ListSchemasAndTables
for InfoSchemaIndexUsageExtractor
and avoid using SchemaTableInfos
.
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.
InfoSchemaIndexUsageExtractor
has already implemented schema and table filter, which is used in tidb_index_usage.
The only difference is that for cluster_tidb_index_usage, the request needs to be sent to all tidb instances for execution
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.
Oops, I forgot to push some code.
func (e *memtableRetriever) setDataFromClusterIndexUsage(ctx context.Context, sctx sessionctx.Context, schemas []model.CIStr) error { | ||
err := e.setDataForClusterIndexUsage(ctx, sctx, schemas) | ||
func (e *memtableRetriever) setDataFromClusterIndexUsage(ctx context.Context, sctx sessionctx.Context) error { | ||
err := e.setDataFromIndexUsage(ctx, sctx) |
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.
What's the difference between clustered_index_usage table and tidb_index_usage 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.
OK, different tidb at the same time may see different schema.
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.
https://docs.pingcap.com/tidb/stable/information-schema-tidb-index-usage#tidb_index_usage
I think each tidb will collect its own index-related statistics.
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.
For example, I ran some query on one node and got this output.
mysql> select * from information_schema.CLUSTER_TIDB_INDEX_USAGE where table_schema = "test" and index_name = "idx_1";
+-----------------+--------------+------------+------------+-------------+--------------+-------------------+---------------------+-----------------------+------------------------+-------------------------+-------------------------+--------------------------+-----------------------+---------------------+
| INSTANCE | TABLE_SCHEMA | TABLE_NAME | INDEX_NAME | QUERY_TOTAL | KV_REQ_TOTAL | ROWS_ACCESS_TOTAL | PERCENTAGE_ACCESS_0 | PERCENTAGE_ACCESS_0_1 | PERCENTAGE_ACCESS_1_10 | PERCENTAGE_ACCESS_10_20 | PERCENTAGE_ACCESS_20_50 | PERCENTAGE_ACCESS_50_100 | PERCENTAGE_ACCESS_100 | LAST_ACCESS_TIME |
+-----------------+--------------+------------+------------+-------------+--------------+-------------------+---------------------+-----------------------+------------------------+-------------------------+-------------------------+--------------------------+-----------------------+---------------------+
| 127.0.0.1:10081 | test | t | idx_1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NULL |
| 127.0.0.1:10080 | test | t | idx_1 | 1 | 1 | 3 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 2024-08-15 09:46:04 |
+-----------------+--------------+------------+------------+-------------+--------------+-------------------+---------------------+-----------------------+------------------------+-------------------------+-------------------------+--------------------------+-----------------------+---------------------+
/assign hi-rustin |
@joechenrh: GitHub didn't allow me to assign the following users: hi-rustin. Note that only pingcap members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. In response to this:
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. |
[LGTM Timeline notifier]Timeline:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: GMHDBJD, hawkingrei, 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 |
/test check-dev2 |
@joechenrh: The specified target(s) for
Use In response to this:
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. |
What problem does this PR solve?
Issue Number: ref #50305
What changed and how does it work?
InfoSchemaIndexUsageExtractor
is added for cluster_tidb_index usage memtable.Besides, the explain output of cluster memory table is changed to make it consistent with other memtable.
Before:
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.