Checking MySQL database sizes

Quick tip: use the below query to check how large each of your MySQL 5 databases is.

mysql> SELECT
  table_schema,
  concat(round(sum(table_rows)/1000000,2),'M') as rows,
  concat(round(sum(data_length)/(1024*1024*1024),2),'G') as data,
  concat(round(sum(index_length)/(1024*1024*1024),2),'G') as idx,
  concat(round(sum((data_length+index_length))/(1024*1024*1024),2),'G') as total_size
FROM information_schema.TABLES
GROUP BY table_schema;
+-----------------------------+-------+-------+-------+------------+
| table_schema                | rows  | data  | idx   | total_size |
+-----------------------------+-------+-------+-------+------------+
| information_schema          | NULL  | 0.00G | 0.00G | 0.00G      | 
| xxxxxxxxx_xxxx_xxxx_staging | 0.93M | 0.08G | 0.01G | 0.09G      | 
+-----------------------------+-------+-------+-------+------------+
2 rows in set (0.03 sec)

Commenting is closed for this article.

About the boy

A picture of Craig in grayscale

Craig Webster is a software engineer living in London. He usually works with Ruby although sometimes he sneaks in some Erlang or JavaScript. He's into rock climbing, snowboarding, skating, photography and fencing. Yes, this does mean he has a sword.

Near here you'll find Craig's homepage, contact details, PGP key and keysigning policy, and talks.

Licence

The entire content of this blog is public domain. Use it however you fancy. You don't even need to attribute it to me, although it would be nice if you did. Just don't sue me and we'll all be happy.

I Work With Rails

Recommend Me

My Travels

I go places. Do you go places too? Let's meet up!.