Skip to content

Instantly share code, notes, and snippets.

@mintsoft
Created June 17, 2013 14:07
Show Gist options
  • Save mintsoft/5797136 to your computer and use it in GitHub Desktop.
Save mintsoft/5797136 to your computer and use it in GitHub Desktop.
Iterate over tables in public schema and run analyze
#!/bin/bash
db="postgres"
psql -qAt -c "SELECT tablename FROM pg_tables WHERE schemaname='public';" $db | while read line; do
psql -qAt -c "ANALYZE $line;" $db;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment