I'm completely new in Postgres optimization. I was reading a lot about checkpoint and WAL files. I found a query to examine the ratio of checkpoints time to requested (exceeded WAL max size)

SELECT checkpoints_timed, checkpoints_req
FROM pg_stat_bgwriter;
checkpoints_timed checkpoints_req
20496 53

In order to minimalize requested checkpoint I changed postgres configuration to:

checkpoint_timeout = 15min  
max_wal_size = 2GB  
min_wal_size = 200MB  

But when I check WAL dir space is still 83MB (as the default value from configuration).

select sum(size)
from pg_ls_waldir(); 

Can anyone explain why WAL directory size is still ~83MB and not increasing to 200MB?

I noted that changing parameters has triggered 2 checkpoints_req so I guess that max_wal_size is still 1GB?

  • What was it that caused the two requested checkpoints?
    – jjanes
    Commented Apr 29, 2023 at 1:28
  • Did you restart Postgresql?
    – RonJohn
    Commented Apr 29, 2023 at 14:27
  • Yes I restarted Postgres, so I understand that number of checkpoints_req is a sum all restarts and backups. Commented May 2, 2023 at 6:10

1 Answer 1


The poorly-named checkpoints_req includes checkpoints requested due to WAL usage, as well as ones requested by things like shutdowns, backups, or manual CHECKPOINT commands. If your checkpoints were performed due to any of those latter causes, there is no reason to think it would imply anything at all about WAL size.

Also, since the vast majority of checkpoints were timed, why are you mucking about with the size parameters anyway? There doesn't seem to be a problem here that needs to be solved. That isn't optimization, just heckling.

  • Ok, now I understand that number of checkpoints_req in my db was caused by restarts and backups. So it's not sense to changing WAL parameter. Commented May 2, 2023 at 6:13
  • But i cant understand why after changing min_wal_size to 300MB. In WAL directory sum of files size is still ~83MB. Commented May 2, 2023 at 6:22
  • @BARTOSZBALA min_wal_size only retains existing wal (by keeping it for future reuse), it doesn't create it from nothing on its own initiative. Until you push another 200MB-83MB of WAL through the system (after increasing min_wal_size), there won't be 200MB there to be retained.
    – jjanes
    Commented May 3, 2023 at 18:10

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.