Find unused indexes in MySQL
Look for indexes with no recorded operations, then check why each index exists before considering removal.
Find unused indexes in MySQL
Section titled “Find unused indexes in MySQL”SELECT OBJECT_SCHEMA AS database_name, OBJECT_NAME AS table_name, INDEX_NAME AS index_name, COUNT_STAR AS total_operations, COUNT_READ AS read_operationsFROM performance_schema.table_io_waits_summary_by_index_usageWHERE OBJECT_SCHEMA = DATABASE() AND INDEX_NAME IS NOT NULL AND INDEX_NAME <> 'PRIMARY' AND COUNT_STAR = 0ORDER BY OBJECT_NAME, INDEX_NAME;The result identifies review candidates. Zero operations means zero recorded use during the available statistics period.
Restarts, counter resets, and index changes can erase earlier activity. Server uptime does not establish when an index’s counters were last reset. MySQL describes the reset behavior in its index I/O summary reference.
Do it in TableAI
Section titled “Do it in TableAI”- Run the SQL in the query editor on the target database.
- Open Admin › Indexes.
- Inspect each candidate’s columns, uniqueness, and definition.
- Check its role in the workload and constraints using the list below.
Before changing an index, confirm that:
- Statistics collection was active throughout a representative workload period.
- The period includes infrequent jobs, such as month-end reports.
- The index does not enforce a unique constraint.
- Foreign keys do not depend on it.
- Query plans still have suitable indexes for important statements.
Use change structure to review proposed index changes and their SQL.
Keep an index until you have evidence that removal is safe. A zero counter alone does not show that an index is unnecessary.
Required access and statistics
Section titled “Required access and statistics”The account needs SELECT access to performance_schema.table_io_waits_summary_by_index_usage. Performance Schema must collect table I/O events for the tables under review.
For missing or empty statistics, use Admin data troubleshooting. Ask the administrator when collection began and whether counters were reset.
Related
Section titled “Related”Use find slow queries to review workload evidence and table size for aggregate index storage. Return to the MySQL overview.