DBAtlas · Database operations atlas

Query table and schema sizes

MySQLStorage

Command

SELECT table_schema AS schema_name, table_name AS table_name, ROUND((data_length + index_length) / 1024 / 1024, 1) AS size_mb FROM information_schema.tables WHERE table_schema NOT IN ('mysql','information_schema','performance_schema','sys') ORDER BY (data_length + index_length) DESC LIMIT 20;

What it does

Lists the 20 largest tables by combined data and index size (MB).

When to use it

To analyze disk usage and find which tables take up space.

Caution

information_schema sizes are approximate for InnoDB. For per-schema totals, GROUP BY table_schema only, instead of table_name.

Open in DBAtlas →

Related