From 492280bd80a49bac463c89ee7cc5f8844b1d6e3f Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 16 Sep 2026 15:03:29 +0900 Subject: [PATCH 1/2] docs: fix schema_unused_indexes source table and restart scope The sys.schema_unused_indexes view (see sys-schema/sys-schema-unused-indexes.md) is defined as SELECT ... FROM information_schema.cluster_tidb_index_usage ... GROUP BY ... HAVING sum(last_access_time) is null, i.e. it is derived from CLUSTER_TIDB_INDEX_USAGE (which aggregates usage across all TiDB instances), not from the single-instance TIDB_INDEX_USAGE. It also flags an index only once none of the cluster's instances have recorded access since their own last restart, not a single cluster-wide restart event. Found while reviewing the Japanese translation of this file, which faithfully mirrored the inaccurate EN wording. Co-Authored-By: Claude Sonnet 5 --- best-practices/index-management-best-practices.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/best-practices/index-management-best-practices.md b/best-practices/index-management-best-practices.md index 48528336537b6..1cab245515a89 100644 --- a/best-practices/index-management-best-practices.md +++ b/best-practices/index-management-best-practices.md @@ -179,7 +179,7 @@ By using `schema_unused_indexes`, you can quickly identify unnecessary indexes a ### How `schema_unused_indexes` works -The `schema_unused_indexes` view is derived from `TIDB_INDEX_USAGE`, meaning it automatically filters out indexes that have recorded zero query activity since the last TiDB restart. +The `schema_unused_indexes` view is derived from `CLUSTER_TIDB_INDEX_USAGE`, meaning it automatically extracts indexes that have not been accessed on any TiDB instance since that instance's last restart. To retrieve a list of unused indexes, run the following SQL statement: From 2f8ab704c1cda489c5890f38812a95507f60f142 Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Fri, 18 Sep 2026 17:38:41 +0900 Subject: [PATCH 2/2] best-practices: clarify per-instance restart scope for schema_unused_indexes CLUSTER_TIDB_INDEX_USAGE aggregates across all TiDB instances, and an index counts as unused only when no instance has recorded access since that instance's own last restart, not since a single cluster-wide restart. Align the intro sentence and considerations heading with the per-instance wording already used elsewhere in this section. Found by CodeRabbit review on PR #23891. Co-Authored-By: Claude Sonnet 5 --- best-practices/index-management-best-practices.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/best-practices/index-management-best-practices.md b/best-practices/index-management-best-practices.md index 1cab245515a89..d4caede0295d0 100644 --- a/best-practices/index-management-best-practices.md +++ b/best-practices/index-management-best-practices.md @@ -167,7 +167,7 @@ By using `CLUSTER_TIDB_INDEX_USAGE`, you can gain a global perspective on index ## Identify unused indexes using `schema_unused_indexes` -Manually analyzing index usage data can be time-consuming. To simplify this process, TiDB provides [`schema_unused_indexes`](/sys-schema/sys-schema-unused-indexes.md), a system view that lists indexes that have not been used since the database is last restarted. +Manually analyzing index usage data can be time-consuming. To simplify this process, TiDB provides [`schema_unused_indexes`](/sys-schema/sys-schema-unused-indexes.md), a system view that lists indexes that have not been accessed on any TiDB instance since that instance's last restart. This provides a quick way for you to do the following: @@ -202,7 +202,7 @@ A result similar to the following is returned: Take the following points into consideration when you use `schema_unused_indexes`. -#### Indexes are considered unused only since the last restart +#### Indexes are considered unused only since each TiDB instance's last restart - If a TiDB node restarts, the usage tracking data is reset. - Ensure the system has been running long enough to capture a representative workload before relying on this data.