MySQL find unused tables

狂风中的少年 提交于 2019-12-05 13:55:25
RolandoMySQLDBA

Try using the INFORMATION_SCHEMA.TABLES

There is a column called UPDATE_TIME

Check the date in that field

If it is NULL, the table has never been updated since the table's creation

Example : A list of tables not updated in the last 10 days

select table_schema,table_name,create_time,update_time from information_schema.tables where table_schema not in ('information_schema','mysql') and engine is not null and ((update_time < (now() - interval 10 day)) or update_time is null);

Give it a try !!!

Try that http://forums.mysql.com/read.php?20,298759,299185#msg-299185

Turning on the "general log" and scanning it (programatically!) would tell you who is hitting what tables during the time the log is on. Caution: that file grows fast.

I know this is an old question, but there doesn't seem to be a proper answer and I was directed here by my own search for an answer. As per Mark Leith's blog post about unused tables and indexes one should be able to do something like this:

SELECT
    t.*
FROM performance_schema.table_io_waits_summary_by_table t
WHERE
    t.COUNT_STAR = 0
    AND t.OBJECT_SCHEMA = '<your-schema-name-goes-here>'
    AND t.OBJECT_TYPE = 'TABLE';

Official documentation about the topic from MySQL gives more details.

It does of course require that you've enabled Performance Schema and that the statistics haven't been cleared/truncated for some time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!