xluffy / til

You only feel happy when you know what you doing
20 stars 1 forks source link

The Insatiable Postgres Replication Slot #236

Open xluffy opened 7 months ago

xluffy commented 7 months ago
SELECT
  slot_name,
  pg_size_pretty(
    pg_wal_lsn_diff(
      pg_current_wal_lsn(), restart_lsn)) AS retained_wal,
  active,
  restart_lsn FROM pg_replication_slots WHERE slot_name LIKE 'gh_%';
         slot_name          | retained_wal | active |  restart_lsn
----------------------------+--------------+--------+---------------
 gh_v2_xxx_yyy_zz  | 18 MB        | t      | 12C2/7935C538
 gh_v2_aaa_bbb_ccc | 20 MB        | t      | 12C2/790DDCE8
 gh_v2_qqq_www_rrr | 16 MB        | t      | 12C2/794C8108
(3 rows)

https://www.morling.dev/blog/insatiable-postgres-replication-slot/