Размер cхем и таблиц MySQL

Запросы для подсчета размера схем и отдельных таблиц сервера MySQL

-- размер схем
SELECT table_schema "database_name", sum( data_length + index_length )/1024/1024 "Database size in MB"
FROM information_schema.TABLES
GROUP BY table_schema
ORDER BY 2 DESC;
-- размер отдельных таблиц
SELECT table_name, table_schema, ( data_length + index_length )/1024/1024 "Table size in MB"
FROM information_schema.TABLES
ORDER BY 3 DESC;
-- размер отдельных таблиц, с типом движка отличным от InnoDB
SELECT table_schema, table_name, table_type, engine, ( data_length + index_length )/1024/1024 "Table size in MB"
FROM information_schema.TABLES
WHERE table_type != "view" AND engine != "InnoDB" AND table_schema NOT IN ("performance_schema", "mysql", "sys")
ORDER BY 3 DESC;

Close Menu