Find out usage statistics of MySQL indices?

R_User picture R_User · Jan 3, 2013 · Viewed 15.4k times · Source

Is it possible to find out how often an index of a MySQL table was used?

I have several indices for a table and I'd like to find out, if there are indice which are not used by MySQL.

Answer

user1970667 picture user1970667 · Apr 4, 2017

Yes, it is. You should query Performance Schema:

select * from performance_schema.table_io_waits_summary_by_index_usage
where object_schema = 'your_schema'

The count_star column show how many times each index was used since MySQL was started. If you add the following, you got the never used indexes:

and count_star = 0