Skip to content

Instantly share code, notes, and snippets.

@doublejosh
Last active May 18, 2016 19:40
Show Gist options
  • Save doublejosh/9376133 to your computer and use it in GitHub Desktop.
Save doublejosh/9376133 to your computer and use it in GitHub Desktop.
Table Size on Pantheon
Query...
SELECT TABLE_NAME as name, TABLE_ROWS as rows, round(((data_length + index_length) / 1024 / 1024), 2) as size
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'tableau_pantheon_www'
AND TABLE_NAME LIKE "%revision%"
ORDER BY size desc;
LOCAL TEST:
mysql --user=root --password=root -e "SELECT UNIX_TIMESTAMP() AS timestamp, round(((data_length + index_length) / 1024 / 1024), 2) as table_size_mb, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'tableau_pantheon_www' AND table_name = '***TABLE_NAME***'"
LIVE QUERY:
mysql -u pantheon -p***PASSWORD*** -h dbserver.live.***HASH***.drush.in -P ***PORT*** pantheon -e "SELECT UNIX_TIMESTAMP() AS timestamp, round(((data_length + index_length) / 1024 / 1024), 2) as table_size_mb, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'pantheon' AND table_name = '***TABLE_NAME***'"
Automatic Logger Bash Script...
while true; do mysql -u pantheon -p***PASSWORD*** -h dbserver.live.***HASH***.drush.in -P ***PORT*** pantheon -e "SELECT UNIX_TIMESTAMP() AS timestamp, round(((data_length + index_length) / 1024 / 1024), 2) as table_size_mb, TABLE_ROWS INFORMATION_SCHEMA.TABLES WHERE table_schema = 'pantheon' AND table_name = '***TABLE_NAME***'" >> /Users/***USER***/Documents/***FOLDER***/table_size_logger.txt; sleep 600; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment