How to Check MySQL Database and Table Size
Find large databases and tables using SQL in seconds.
Before you start
Check database size
SELECT count(*) NUM_OF_TABLE,
table_schema,
concat(round(sum(table_rows)/1000000,2),'M') rows,
concat(round(sum(data_length)/(1024*1024*1024),2),'G') DATA,
concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx,
concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size,
round(sum(index_length)/sum(data_length),2) idxfrac
FROM information_schema.TABLES
GROUP BY table_schema
ORDER BY sum(data_length+index_length) DESC
LIMIT 10;
DATA = data size, idx = index size, total_size = total usage.
Check table size
SELECT
table_name,
table_rows,
round(data_length/(1024*1024),2) AS DATA_SIZE_MB,
round(index_length/(1024*1024),2) AS INDEX_SIZE_MB
FROM information_schema.TABLES
WHERE table_schema = 'your_database_name'
ORDER BY data_length DESC;
Replace 'your_database_name' with your actual database name.
Common issues
In InnoDB, row count is approximate.
You need access to information_schema.
Make sure you replace the schema name correctly.