title: Disk space Postgres database gets full eventhough Vacuum
body: <p>I have a database which is constantly written by different servers. The problem I have is that even though I <code>vacuum</code> the database, the disk available is progressively in time getting reduced. This is an image of a 16 day period:</p>
  <p><a href="https://i.stack.imgur.com/XbMGq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XbMGq.png" alt="enter image description here" /></a></p>
  <p>As you see the trend is decreasing the memory available.
  If I zoom in on a certain interval:</p>
  <p><a href="https://i.stack.imgur.com/q81XV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q81XV.png" alt="enter image description here" /></a></p>
  <p>I can see that that at some point in time the VACUUM happens (I guess it is the pick going down even though it does not make much sense as it should go up instead of down).</p>
  <p>I have a configuration in <code>/etc/cron.daily/&lt;database name&gt;</code> as:</p>
  <pre class="lang-none prettyprint-override"><code>#!/bin/bash
  set -e
  
  LIMIT=$(date -d '-2 months' +'%Y-%m-%dT00:00:00')
  
  CMD=&quot;delete from source_stat where slot &lt; '$LIMIT'&quot;
  su postgres -c &quot;psql datacare -c \&quot;$CMD\&quot;&quot;
  
  CMD=&quot;delete from request_stat where slot &lt; '$LIMIT'&quot;
  su postgres -c &quot;psql datacare -c \&quot;$CMD\&quot;&quot;
  
  CMD=&quot;delete from perf_stat where slot &lt; '$LIMIT'&quot;
  su postgres -c &quot;psql datacare -c \&quot;$CMD\&quot;&quot;
  
  su postgres -c &quot;psql datacare -c VACUUM&quot;
  </code></pre>
  <p>to remove data older than 2 months, and this works. Then, I do not understand why on average the free disk size gets reduced. Insertions in the database are pretty constant in time so if older data gets removed it should counteract new data coming in. Moreover, it does not make much sense that I have moments with flat steep and moments with high steep.</p>
  <p>Postgres version: <code>PostgreSQL 9.5.7</code></p>