Skip to content

Instantly share code, notes, and snippets.

@Likeyn
Last active August 29, 2015 14:04
Show Gist options
  • Save Likeyn/09433d66edb0a08dbb20 to your computer and use it in GitHub Desktop.
Save Likeyn/09433d66edb0a08dbb20 to your computer and use it in GitHub Desktop.
Attempt to compute the physical size of databases / tables
SELECT
TABLE_SCHEMA AS 'Database',
TABLE_NAME AS 'Table',
ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) 'Size in MB'
FROM information_schema.TABLES
WHERE
TABLE_SCHEMA = '<database_name>'
AND TABLE_NAME = '<table_name>'
ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment