my main question - why pg_wal dir is extremely growing up?

I have two postgresql instances.

The first was set up as master:

wal_level: "logical"
max_wal_senders: 5
max_replication_slots: 10

Also, I was enable archiving for pg_wal:

archive_mode: on
archive_command: 'gzip < %p > /.../data/pg_wal_archive/%f'

After that, PUBLICATION was created for some of my tables (not ALL TABLES)

For replication psql instance - I using default psql config, only created SUBSCRIPTION to master.

And I have two questions:

  1. I run some script on master, which pulling ~ 10 Gb data to one table, which was not included in the PUBLICATION. And, I see, that my pg_wal dir size is increasing anyway. Why?

  2. Why pg_wal dir does not cleaning? Is it normal? Looks like I have some data for restore table which is not using in replication, how to delete this data?

  • Looks like archive_mode: should be off, and files in pg_wal will be auto replaced... Will check it...
    – vintik
    Commented Aug 12, 2019 at 13:34

1 Answer 1


archive_mode is used for for archiving, regardless of standby configuration. It can be used for point in time recovery. So when you perform DML on any table, it will generate WAL.

For cleaning up you can use archive_cleanup_command from recovery.conf

  • Yep, still reading psql docs, looks lime my mistake was in turning on archive_mode. Still have a lot of questions about wal, if my replica was going down - should I expect growing up pg_wal dir?
    – vintik
    Commented Aug 13, 2019 at 18:35
  • well, if standby goes down and recovery.conf was responsible for cleaning up, then pg_wal will increase. I would suggest creating a job to clean up your old WAL as per your retention requirements.
    – CAM
    Commented Aug 16, 2019 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.