warning
hosted, paid — --remote
SET TABLESPACE copying the table under full lock
Warning — this works, but blocks traffic or rewrites data at scale.
What it catches
Moving a table to another tablespace physically copies every block while holding ACCESS EXCLUSIVE. Copy time scales with table size; the table is unavailable throughout.
Fires on
ALTER TABLE orders SET TABLESPACE fast_ssd;Do this instead
Move the table online with pg_repack --tablespace, which rebuilds it in the target tablespace without holding ACCESS EXCLUSIVE for the copy. Otherwise schedule the move in a maintenance window with a lock_timeout guard — the copy itself cannot be made non-blocking with plain SQL. Indexes can move separately (ALTER INDEX ... SET TABLESPACE) to shrink each outage.
-- online, no migration needed:
-- pg_repack --table=orders --tablespace=fast_ssd
-- or accept the copy in a maintenance window, guarded:
-- SET lock_timeout = '5s';
-- ALTER TABLE orders SET TABLESPACE fast_ssd;Catch this before it ships
This rule runs in the hosted service on Startup and above — add --remote with a team token, or use the GitHub Action: npx bolvrk check migration.sql