Last active
September 17, 2016 05:00
-
-
Save lfittl/f1da5bbfda4dcfcf36ff7517373bfe4d to your computer and use it in GitHub Desktop.
Running ANALYZE (or other table-specific commands) across distributed tables in a Citus cluster
This file contains hidden or 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
| # Analyzes all distributed tables | |
| export PGHOST=... | |
| export PGUSER=citus | |
| export PGPASSWORD=... | |
| #export PGSSLMODE=require | |
| export PGDATABASE=citus | |
| export PARALLEL_FACTOR=4 | |
| psql -tA -F" " -c "SELECT logicalrelid::regclass||'_'||s.shardid, \ | |
| nodename, nodeport FROM pg_dist_shard s JOIN pg_dist_shard_placement p ON (s.shardid = p.shardid)" | | |
| xargs -n 3 -P $PARALLEL_FACTOR sh -c "psql -h \$1 -p \$2 -c \"ANALYZE \$0\"" |
This file contains hidden or 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
| # Analyzes a specific distributed table | |
| export PGHOST=... | |
| export PGUSER=citus | |
| export PGPASSWORD=... | |
| #export PGSSLMODE=require | |
| export PGDATABASE=citus | |
| export TABLE_NAME=impressions | |
| export PARALLEL_FACTOR=4 | |
| psql -tA -F" " -c "SELECT logicalrelid::regclass||'_'||s.shardid, \ | |
| nodename, nodeport FROM pg_dist_shard s JOIN pg_dist_shard_placement p ON (s.shardid = p.shardid) \ | |
| WHERE logicalrelid::regclass = '$TABLE_NAME'::regclass;" | | |
| xargs -n 3 -P $PARALLEL_FACTOR sh -c "psql -h \$1 -p \$2 -c \"ANALYZE \$0\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment