Question

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.

Was it helpful?

Solution 3

NOTE: This answer is no longer valid as of 5.5.3!

See https://stackoverflow.com/a/43205887/1251127

Original answer below.

Currently, MySQL does not offer statistics on index usage.

One way to generate those stats on your own would be to log all queries (Be careful of the extra i/o here) and parse it out. Percona has a nice tool for this, pt-index-usage.

OTHER TIPS

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

Addition to @user1970667's answer, you may also use:

select * from sys.schema_unused_indexes;

to get a list of unused indexes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top