Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 查找用不到的索引
[Question] Current Issue
I want to be able to find redundant and unused indexes, just like in MySQL.
[Business Impact]
[TiDB Version] v5.2.2
[Application Software and Version]
[Attachments] Relevant logs and configuration information
TiDB currently does not have system tables similar to schema_redundant_indexes and schema_unused_indexes under the MySQL sys schema. At present, you can use the dashboard to optimize slow SQL queries.
Currently, you can check this table information_schema.tidb_indexes
, and you need to determine the results yourself.
INFORMATION_SCHEMA.SCHEMA_INDEX_USAGE
Reference: tidb/docs/design/2020-09-30-index-usage-information.md at master · pingcap/tidb · GitHub
But it’s best to search before asking: TiDB 索引优化 - #7,来自 ealam_小羽 - TiDB 的问答社区 , this post already has similar questions.
Is this feature implemented? My table here is empty.
mysql> select version()\G
*************************** 1. row ***************************
version(): 5.7.25-TiDB-v6.2.0-alpha
1 row in set (0.00 sec)
mysql> select * from mysql.SCHEMA_INDEX_USAGE;
Empty set (0.00 sec)
mysql> select * from INFORMATION_SCHEMA.SCHEMA_INDEX_USAGE;
ERROR 1146 (42S02): Table 'information_schema.SCHEMA_INDEX_USAGE' doesn't exist
In the MySQL database, but it seems there is no data.
Well, what the person above wrote is I_S. The main point here is that the sys schema unused index feature in MySQL 8 has not yet been implemented in TiDB.
My bad, it seems it hasn’t been implemented yet. I thought it was because I was using version 4.0.16.
To be honest, MySQL is not used that often either.
You can actually write a SQL query to reverse check for unused indexes.
This topic was automatically closed 60 days after the last reply. No new replies are allowed.