Last active
September 19, 2017 16:59
-
-
Save marcocitus/27d91226ac248591c97c to your computer and use it in GitHub Desktop.
Shell commands to ALTER a CitusDB distributed table
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
TABLE_NAME=customer_reviews | |
ALTER_COMMAND="ALTER COLUMN customer_id SET STATISTICS 1000" | |
/opt/citusdb/3.0/bin/psql -h localhost -d postgres -c "ALTER TABLE $TABLE_NAME $ALTER_COMMAND" | |
/opt/citusdb/3.0/bin/psql -tA -F" " -h localhost -d postgres -c "select relname, s.shardid, p.nodename, p.nodeport from pg_class c, pg_dist_shard s, pg_dist_shard_placement p where s.logicalrelid = c.oid and s.shardid = p.shardid and relname = '$TABLE_NAME'" | xargs -n 4 -P 100 sh -c '/opt/citusdb/3.0/bin/psql -h $3 -p $4 -d postgres -c "ALTER TABLE $1_$2 $0;"' "$ALTER_COMMAND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment