#!/bin/sh skip_fillrate=90 skip_size=1048576 full_vacuum_size=1073741824 pgsql() { psql -d "$1" -Aqt < $skip_size;"` if [ "$size" != "" ]; then if [ "$size" -gt "$full_vacuum_size" ] ; then echo "$database: simple vacuum and analyze table $table" pgsql "$database" " VACUUM ANALYZE $table;" else echo "$database: full vacuum and analyze table $table" pgsql "$database" " VACUUM FULL ANALYZE $table;" fi fi done echo "$database: vacuum and analyze" pgsql "$database" " VACUUM ANALYZE;" done