Last active
February 20, 2017 04:00
-
-
Save saicitus/408bd0cc770974503fff79fef489f1c1 to your computer and use it in GitHub Desktop.
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
export PGHOST=... | |
export PGUSER=citus | |
export PGPASSWORD=... | |
export PGSSLMODE=require | |
export PGDATABASE=citus | |
export TABLE_NAME=events | |
export NEW_TABLE_NAME=events_backup | |
export PARALLEL_FACTOR=4 | |
psql -tA -F" " -c "SELECT 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 \"ALTER TABLE ${TABLE_NAME}_\$0 RENAME TO ${NEW_TABLE_NAME}_\$0\"" | |
export PGOPTIONS="-c citus.enable_ddl_propagation=off" | |
psql -c "ALTER TABLE $TABLE_NAME RENAME to $NEW_TABLE_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment