Skip to content

Instantly share code, notes, and snippets.

@prathe
Last active July 20, 2021 17:24
Show Gist options
  • Save prathe/934734c5555a8798abf18045bc81a3d4 to your computer and use it in GitHub Desktop.
Save prathe/934734c5555a8798abf18045bc81a3d4 to your computer and use it in GitHub Desktop.

Show all unused index since the last MySQL server restart (MySQL 5.6+)

SELECT object_schema, object_name, index_name
FROM performance_schema.table_io_waits_summary_by_index_usage 
WHERE index_name IS NOT NULL AND count_star = 0
ORDER BY object_schema, object_name;
@prathe
Copy link
Author

prathe commented Jul 20, 2021

SELECT object_schema, object_name, index_name, count_star
FROM performance_schema.table_io_waits_summary_by_index_usage 
WHERE object_schema='my_app' AND index_name='index_bar_on_foo'
ORDER BY object_schema, object_name;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment