Skip to content

Instantly share code, notes, and snippets.

@bfodeke
Created March 28, 2022 18:10
Show Gist options
  • Save bfodeke/84f33f17b460a5d80f4a8bbe524d4b6c to your computer and use it in GitHub Desktop.
Save bfodeke/84f33f17b460a5d80f4a8bbe524d4b6c to your computer and use it in GitHub Desktop.
Query the database to view tables by size. Replace `[database_name]` with the name of your database
SELECT table_name AS 'Table', TABLE_ROWS as 'Num. of Rows', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB'
FROM information_schema.TABLES where table_schema = '[database_name]'
ORDER BY (data_length + index_length) DESC
LIMIT 200;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment