PostgreSQL database size is less after backup/load on Heroku PostgreSQL database size is less after backup/load on Heroku database database

PostgreSQL database size is less after backup/load on Heroku


It is ok for postgresql DB to consume more space when in use.

The reason of this is its MVCC system. Every time you UPDATE any record in a database it creates another "version" of this record instead of rewriting the previous. This "outdated" records will be deleted by VACUUM process, when there will be no need in them.

So, when you restored your db from backup, it didn't have any "dead" records and its size was less.

Details here http://www.postgresql.org/docs/current/static/mvcc.html and http://www.postgresql.org/docs/current/static/sql-vacuum.html.

P.S. You do not need to worry about it. Postgresql will handle VACUUM automatically.


See if this helps: PostgreSQL database size increasing

Also try to measure the size of each table individually and for those tables where you see differences, compare counts of records: postgresql total database size not matching sum of individual table sizes