Query MySQL Table Sizes
Add a commentcheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.
The following query lists all tables within a MySQL instance along with their row counts and sizes in MiB:
SELECT
table_schema as `database`,
table_name as `table`,
table_rows as `rows`,
ROUND(((data_length + index_length) / 1024 / 1024), 2) `size_mib`
FROM information_schema.tables
ORDER BY (data_length + index_length) DESC;