0

We backed up, deleted and restored several databases. Surprisingly, the databases occupy 20% less storage space afterwards. Have we lost data or what could have happened here? Autovacuum runs regularly.

Example:

df -h /var
pg_dump -Fc -f <file> <database>
dropdb <database>
createdb <database>
pg_restore -d <database> <file>
df -h /var
asked Jul 19, 2023 at 12:33

2 Answers 2

1

You had some bloated tables or indexes in the original database.

To diagnose bloat, use the pgstattuple extension.

To get rid of bloat, use VACUUM (FULL).

To avoid bloat, keep your transactions short, tune autovacuum to be fast enough and avoid mass deletions.

answered Jul 19, 2023 at 12:47
1
  • Thank you for your explanation. Commented Jul 20, 2023 at 8:04
0

The default setting of autovacuum_vacuum_scale_factor is 0.2, so 20% empty space is entirely unremarkable when autovacuum is running as designed.

answered Jul 20, 2023 at 1:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.