0

I monitor the amount of WAL files in pg_wal. Overtimes, it reduces by itself. I dont have clustering, just single server with logical replication.

My parameter :

archive_timeout = 3600
min_wal_size = 2 GB
max_wal_size = 16 GB
wal_keep_segment = 4000
archiving_mode = ON
archive command = test ! -f /archive/%f && cp %p /archive/%f
wal_level = logical

What are the reasons the amount of WALs reduce ? I try to look for articles but never found one. Please point me to one or maybe answer this.

Thanks

padjee
  • 125
  • 2
  • 12

1 Answers1

0

WAL segments are automatically deleted if they are no longer needed. Also, PostgreSQL automatically creates new WAL segments for future use, and the number of such segments depends on the amount of data modification activity. So it is totally normal for the size of pg_wal to vary with the amount of data modification activity.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Hi @LaurenzAlbe, are they actually reduced and recycled ? the amount of WALs should stay somewhere around `wal_keep_segment` during low / non-busy times. Correct ? – padjee Sep 06 '22 at 15:54
  • If there is low activity, WAL size will approach `wal_keep_size` + `min_wal_size`. – Laurenz Albe Sep 06 '22 at 16:13
  • So, what `wal_keep_segment = 4000` indicating ? I thought it indicates the maximum amount of WAL that reside on `pg_wal` directory @LaurenzAlbe – padjee Sep 06 '22 at 16:42
  • `wal_keep_size` (`wal_keep_segments` in older releases) determines the minimum **old and unused** WAL segments that PostgreSQL keeps around. – Laurenz Albe Sep 06 '22 at 16:48