I have a set of servers where the maintenance query execution takes long. This is due to the indexes that are created by the developers at different points. Is there any way to monitor the unused indexes that adversely affect the execution.
In Oracle SQL Developer, when you have SQL in the worksheet, there is a button "Explain Plan", you can also hit F10. After you execute Explain plan, it will show in the bottom view of SQL Developer. There is a column "OBJECT_NAME", it will tell you what index is being used.
Your answer To see the index for a specific table use SHOW INDEX: SHOW INDEX FROM yourtable; To see indexes for all tables within a specific schema you can use the STATISTICS table from INFORMATION_SCHEMA: SELECT DISTINCT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.
Indexes are one of the most important features of the SQL Server while being most overlooked and misused in practice. Their proper use leads to great server performance, but having them set up incorrectly or not having them set up at all, leads to poor execution times.
dm_db_index_usage_stats DMV result helps to decide if we need to remove that index or replace it with more optimal one.
For mysql 5.6 before
By Default package of mysql does not have much statistics for analysis but there are some unofficial patches by which you can analyze.
like userstats http://ourdelta.org/docs/userstats
By This patch you can analyze the stats and unused indexes.
Follow the below links to do that
https://www.percona.com/blog/2012/06/30/find-unused-indexes/
In MySQL 5.6 and later, the PERFORMANCE_SCHEMA tracks index IO. If an index has no IO activity, it has not been used.
The sys schema now provides a convenient view to make it easier to identify unused indexes:
http://www.markleith.co.uk/2011/04/18/monitoring-table-and-index-io-with-performance_schema/
DROP VIEW IF EXISTS unused_indexes;
CREATE VIEW unused_indexes AS
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;
Note that this shows indexes that haven't been used since the last restart of mysqld. The PERFORMANCE_SCHEMA statistics are reset at startup time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With