I want to have advice about WAL management. I am expecting a large numbers of wal files (the database is very large and it has like 30 - 40 millions of records in totals) since I am setting up a Logical replication for some tables.
Currently, using this query :
SELECT COUNT(*) FROM pg_ls_dir('pg_wal') WHERE pg_ls_dir ~ '^[0-9A-F]{24}'; I find 6817 files. My goal is to reduce this number to just 10 - 20 files maximum.
- How do this without affecting any other things such as restore etc ? Currently, the min WAL size is 1GB and the max is 4GB.
- Suppose I just want 10 files. How to zip the rest 6807 files ?
- If I want to do the whole process automatically, what do I have to do / set ?
I am using PG 12.11 running on Ubuntu 20.04
Thanks. BTW, I am new to PG.
min_wal_sizeis reached. It might take a while though, but eventually they will be gone. Never, ever mess with thepg_waldirectory manually. Nevermax_wal_sizesetting, and reduce to be 80MB. That should do it. If not, then you might have problem with broken archiving, or old replication slots, or wal_keep_size, or prepared transactions. Hard to say. For debugging I'd suggest you ask on irc/slack/discord, as it will more of a conversation than "here you go: do a, b, c".