Skip to content

Instantly share code, notes, and snippets.

@crittermike
Created August 18, 2016 13:22
Show Gist options
  • Save crittermike/b1281d8e7d8bad4a86c8647fb82cc38e to your computer and use it in GitHub Desktop.
Save crittermike/b1281d8e7d8bad4a86c8647fb82cc38e to your computer and use it in GitHub Desktop.
Determining size of MySQL DB dump and individual tables before dumping it
SELECT
TABLE_SCHEMA,
TABLE_NAME,
DATA_LENGTH / POWER(1024,1) Data_KB,
DATA_LENGTH / POWER(1024,2) Data_MB,
DATA_LENGTH / POWER(1024,3) Data_GB
FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','performance_schema','mysql') ORDER BY DATA_LENGTH;
SELECT
Data_BB / POWER(1024,1) Data_KB,
Data_BB / POWER(1024,2) Data_MB,
Data_BB / POWER(1024,3) Data_GB
FROM (SELECT SUM(data_length) Data_BB FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','performance_schema','mysql')) A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment