Skip to content

Instantly share code, notes, and snippets.

@thomasbilk
Last active December 31, 2021 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save thomasbilk/1986815 to your computer and use it in GitHub Desktop.
Save thomasbilk/1986815 to your computer and use it in GitHub Desktop.
Database Sizes
-- PostgreSql
SELECT
pg_database.datname AS "Database Name",
pg_database_size(pg_database.datname) / 1024.0 / 1024.0 AS "Database Size (MB)"
FROM pg_database;
-- MySql
SELECT
table_schema "Database Name",
sum( data_length + index_length ) / 1024 / 1024 "Database Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment