LoginSignup
0
0

データベース テーブルサイズ一覧

Posted at

データベース内にある各テーブルのサイズをチェック!

頻繁に使わないのでいざ使うときに毎回調べてたのをメモメモ

SELECT 
	table_name,
	floor((data_length+index_length) / (1024 * 1024)) AS table_size,
    floor(data_length / (1024 * 1024)) AS table_data_size,
    floor(index_length / (1024 * 1024)) AS table_index_size ,
    table_rows,
    avg_row_length
FROM information_schema.tables 
WHERE table_schema = database() 
ORDER BY table_size DESC;

余談

確認すると想定とは違うことが偶にある
まさか通知メールのテーブルがが全体の2/3を占めるほど大きかったとは、、、
バックアップ無駄なので退避DB作って一定期間過ぎたらそっちに移動しよう

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0