Skip to content

Instantly share code, notes, and snippets.

@dansku
Last active March 26, 2019 15:40
Show Gist options
  • Select an option

  • Save dansku/d1ac47f8ed47f8c65cba53885a4e2c05 to your computer and use it in GitHub Desktop.

Select an option

Save dansku/d1ac47f8ed47f8c65cba53885a4e2c05 to your computer and use it in GitHub Desktop.

Calculate database size:

SELECT table_schema "db_name",
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" 
FROM information_schema.tables 
GROUP BY table_schema; 

Count total rows in database:

SELECT SUM(TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'db_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment