Skip to content

Instantly share code, notes, and snippets.

@xtfer
Created October 14, 2016 00:36
Show Gist options
  • Save xtfer/b09a119b04d293092de3360aeffe0d7e to your computer and use it in GitHub Desktop.
Save xtfer/b09a119b04d293092de3360aeffe0d7e to your computer and use it in GitHub Desktop.
Estimate mysql size
SELECT
table_name,
data_length/1048576,index_length/1048576,
(data_length+index_length)/1048576 as data_used,
data_free/1048576 as data_free,
(data_length+index_length+data_free)/1048576 as disk_used
FROM information_schema.tables where table_schema = 'main'
ORDER BY (data_length+index_length+data_free) ASC;
SELECT
SUM(index_length)/1048576 as index_length,
SUM(data_length)/1048576 as data_length,
SUM(data_free)/1048576 as data_free,
SUM(data_length+index_length+data_free)/1048576 as disk_used,
(COUNT(*) * 300 * 1024)/1048576 as overhead,
(SUM(data_length+index_length+data_free) + (COUNT(*) * 300 * 1024))/1048576+150 as estimated_actual_disk_usage
FROM information_schema.tables where table_schema = 'main';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment