postgresqlpostgresql-13pgbackrest

PostgreSQL: even read access changes data files disk leading to large incremental backups using pgbackrest


We are using pgbackrest to backup our database to Amazon S3. We do full backups once a week and an incremental backup every other day. Size of our database is around 1TB, a full backup is around 600GB and an incremental backup is also around 400GB!

We found out that even read access (pure select statements) on the database has the effect that the underlying data files (in /usr/local/pgsql/data/base/xxxxxx) change. This results in large incremental backups and also in very large storage (costs) on Amazon S3.

Usually the files with low index names (e.g. 391089.1) change on read access.

On an update, we see changes in one or more files - the index could correlate to the age of the row in the table.

Some more facts:

We see the phenomenon on multiple servers.

Can someone explain, why postgresql changes data files on pure read access? We tested on a pure database without any other resources accessing the database.


Solution

  • This is normal. Some cases I can think of right away are:

    The only way to fairly reliably prevent PostgreSQL from modifying a table in the future is: