This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How much space, in bytes, is used by the tables in this database? | |
psql -c "SELECT tablename FROM pg_tables WHERE schemaname = 'public'" | sed -r "s/(.*)/\"SELECT * FROM pg_total_relation_size('\1')\"/g" | xargs -n 1 psql -c | egrep "\s+[0-9]+" | tr -d ' ' | awk '{total = total + $1}END{print total}' | |
# How much space, in bytes, is used by the indexes in this database? | |
psql -c "SELECT tablename FROM pg_tables WHERE schemaname = 'public'" | sed -r "s/(.*)/\"SELECT * FROM pg_indexes_size('\1')\"/g" | xargs -n 1 psql -c | egrep "\s+[0-9]+" | tr -d ' ' | awk '{total = total + $1}END{print total}' | |
# This is not a proud gist. |
NewerOlder