データベース毎の使用容量
1 2 3 4 5 6 7 | SELECT table_schema , ROUND( SUM (data_length + index_length) / 1024 / 1024, 1) AS 'size(MB)' FROM information_schema.tables GROUP BY table_schema; |
結果
1 2 3 4 5 6 7 | + --------------------+----------+ | table_schema | size (MB) | + --------------------+----------+ | db_a | 77.0 | | db_b | 17.3 | | information_schema | 0.0 | + --------------------+----------+ |
テーブル毎の使用容量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 調べたいデータベースに切り替え USE db_a SELECT table_name , FLOOR((data_length + index_length) / 1024 / 1024) AS 'all(MB)' , FLOOR((data_length) / 1024 / 1024) AS 'data(MB)' , FLOOR((index_length) / 1024 / 1024) AS 'index(MB)' , table_rows AS 'tbl rows' , avg_row_length AS 'row avg(B)' FROM information_schema.tables WHERE table_schema = DATABASE () ORDER BY (data_length + index_length) DESC ; |
結果
1 2 3 4 5 6 | + ------------+---------+----------+-----------+----------+------------+ | table_name | all (MB) | data(MB) | index (MB) | tbl rows | row avg (B) | + ------------+---------+----------+-----------+----------+------------+ | table_a | 16 | 8 | 8 | 15791 | 532 | | table_b | 0 | 0 | 0 | 780 | 588 | + ------------+---------+----------+-----------+----------+------------+ |
all(MB) テーブル全体のサイズ
data(MB) データファイルのサイズ
index(MB) インデックスファイルのサイズ
tbl rows レコード件数
row avg(B) 平均レコードサイズ