How to Vacuum FULL on Primary node with Streaming replication in Postgresql 11

2k Views Asked by At

On production I have database of size 150 GB. Many rows are deleted from this table and Vacuum is applied on this. Now I need to release unused space from DB to disk for OS. So Vacuum Full needs to be applied. Streaming replication is configured on production server with three secondary nodes. What is best way ?

  1. Pause replication and run Vacuum FULL on master node. And then Start replication again.
  2. Stop replication and and recreate after Vacuum FULL on master node.
1

There are 1 best solutions below

2
On BEST ANSWER

You need to do nothing of the above. VACUUM (FULL) is replicated just like any other data modification.

On the standby servers the same restriction applies as on the primary server: while VACUUM (FULL) is running, the affected tables are locked to any concurrent access.

Since VACUUM (FULL) rewrites the table, it will generate a lot of WAL, so of course replication performance may be affected. But stopping replication will only delay, not reduce that, and rebuilding the standby will generate even more traffic.