title: PostgreSQL 9.6 wals management
body: <p>I'm trying to understand my wals behavior on my PostgreSQL environment. My wal settings are :</p>
  <pre><code>wal_keep_segments = 200
  max_wal_size = 3GB
  min_wal_size = 80MB
  archive_command = 'cp %p /PostgreSQL-wal/9.6/pg_xlog/wal_archives/%f' 
  archive_timeout = 10
  #checkpoint_flush_after = 256kB
  #checkpoint_completion_target = 0.5
  </code></pre>
  <p>My wals directory is <code>/PostgreSQL-wal/9.6/pg_xlog/</code> and my archives directory is <code>PostgreSQL-wal/9.6/pg_xlog/wal_archives</code>. Last night my wals directory storage got full (archive directory also because they are on the same filing system).</p>
  <p>I have right now 211 wals in my wals directory :</p>
  <pre><code>ls -l /PostgreSQL-wal/9.6/pg_xlog/ | wc -l
  212
  </code></pre>
  <p>The only thing that was running during the night are only selects from our monitoring agent. I guess that wal were created because the archive_timeout was very low and they were deleted because the wal_keep_segments was high.</p>
  <p>This morning, I set the wal_keep_segments to 100 and I set the archive_timeout to 6 minutes. Now, after setting those settings and starting the cluster wals switch is working fine and I didn't see that many wals were created. However, doesn't the old wals should be deleted automatically ? Can I delete archives safely ?</p>