dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Scripts Library/mysql/#30
Script #30
mysql
Performanceread-onlyMin Version: 5.7

Find Redundant Indexes in MySQL

Lists indexes already covered by another index, with a ready-to-use DROP statement. Reduces write load and disk usage.

#redundant-index#sys-schema#cleanup
mysql · sql
SELECT table_schema, table_name,
       redundant_index_name, redundant_index_columns,
       dominant_index_name,  dominant_index_columns,
       sql_drop_index
FROM sys.schema_redundant_indexes
WHERE table_schema NOT IN ('mysql','sys');
Operational Notes & Remediation Guidance

Drop redundant prefixes using `ALTER TABLE ... DROP INDEX ...` to reduce write I/O and disk bloat.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 5.7).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.