Disclaimer: The below guide is more relevant if you are using read replicas or your Postgres instance is below Postgres 14.
For primary Postgres instances of versions 14 and above, PeerDB now has inbuilt functionality to mitigate slot growth by default.
heartbeat table in the source database.
Creating a heartbeat table on Postgres
This table will have a single row that gets updated every minute.
By including this table in the CDC mirror, PeerDB will pick up changes to this table, sync them and flush the slot periodically, keeping the slot size in check.
The below is an example of what we’re talking about. Ensure that the heartbeat table has required permissions to be a part of the mirror.
PeerDB Implementation
PeerDB has the facility to perform periodic updates on your heartbeat table. This has the benefit of not needing to install an extension like pg_cron. Currently, updates are done every 12 minutes. This will soon be configurable. PeerDB will require update permission on the heartbeat table:Settings in the sidebar. Search for WAL in the search bar on the right.
Edit the current value fields of the following settings:
PEERDB_ENABLE_WAL_HEARTBEAT: Set this totrue(no quotes or anything)PEERDB_WAL_HEARTBEAT_QUERY: Set this to the update command to be run periodically:


