Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions best-practices/index-management-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 an index when none of the TiDB instances currently has an access record for that index. Index usage is tracked separately on each TiDB instance and is reset when that instance restarts.

This provides a quick way for you to do the following:

Expand All @@ -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`. It returns an index only if no TiDB instance has recorded an access to it since its own most recent restart.

To retrieve a list of unused indexes, run the following SQL statement:

Expand All @@ -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
#### Index usage data is reset when a TiDB instance restarts

- 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.
Expand Down
Loading