-- 查看sql执行次数 SELECT DIGEST_TEXT, COUNT_STAR AS EXECUTION_COUNT FROM performance_schema.events_statements_summary_by_digest WHERE COUNT_STAR > 0 ORDER BY EXECUTION_COUNT DESC;
1 2 3 4 5 6 7 8 9 10
-- 查看占用时间 SELECT DIGEST_TEXT, MAX_TIMER_WAIT / 1000000 AS MAX_EXECUTION_TIME_MS FROM performance_schema.events_statements_summary_by_digest WHERE MAX_TIMER_WAIT IS NOT NULL ORDER BY MAX_EXECUTION_TIME_MS DESC;
1 2 3 4 5 6 7 8 9
-- 查看表空间大小 SELECT table_schema AS `Database`, table_name AS `Table`, ROUND(((data_length + index_length) / 1024 / 1024), 2) AS `Size (MB)` FROM information_schema.tables WHERE table_schema = 'table_name';
1 2 3 4 5 6
-- 查询数据库占用空间 SELECT table_name AS `Table`, ROUND((data_length + index_length) / 1024 / 1024, 2) AS `Size (MB)` FROM information_schema.tables WHERE table_schema = 'your_database_name' ORDER BY (data_length + index_length) DESC;
1 2 3 4 5 6
-- 查看binlog 文件 SHOW BINARY LOGS;
-- 查看 binlog文件内容 SHOW BINLOG EVENTS IN 'mysql-bin.001596' LIMIT 5000;