I have a database which is constantly written by different servers. The problem I have is that even though I vacuum
the database, the disk available is progressively in time getting reduced. This is an image of a 16 day period:
As you see the trend is decreasing the memory available. If I zoom in on a certain interval:
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).
I have a configuration in /etc/cron.daily/<database name>
as:
#!/bin/bash
set -e
LIMIT=$(date -d '-2 months' +'%Y-%m-%dT00:00:00')
CMD="delete from source_stat where slot < '$LIMIT'"
su postgres -c "psql datacare -c \"$CMD\""
CMD="delete from request_stat where slot < '$LIMIT'"
su postgres -c "psql datacare -c \"$CMD\""
CMD="delete from perf_stat where slot < '$LIMIT'"
su postgres -c "psql datacare -c \"$CMD\""
su postgres -c "psql datacare -c VACUUM"
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.
Postgres version: PostgreSQL 9.5.7