Created
March 14, 2015 10:59
-
-
Save marcocitus/601b49c343bc910e97bd to your computer and use it in GitHub Desktop.
Shell commands to ALTER a pg_shard 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" | |
psql -h localhost -d postgres -c "ALTER TABLE $TABLE_NAME $ALTER_COMMAND" | |
psql -tA -F" " -h localhost -d postgres -c "select relname, s.id, p.node_name, p.node_port from pg_class c, pgs_distribution_metadata.shard s, pgs_distribution_metadata.shard_placement p where s.relation_id = c.oid and s.id = p.shard_id and relname = '$TABLE_NAME'" | xargs -n 4 -P 100 sh -c '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