I use node-pg-migrate and Amazon RDS Postgres on a development environment where I'm the process of building an app.
Sometimes I migrate all the way down so that the database is almost as it was when I created the instance.
I found recently that when I did several migrations up and down again, that I ran out of storage (5GB) after the last up migration. After I migrated fully down not the full 5GB is available. That may be because some persistent objects occupy some space.
Nevertheless, I noticed when I ran VACUUM FULL
, that more storage was available.
Update. It turns out that more storage may have also become available due to autovacuum which may have coincided with my VACUUM FULL
query within graph accuracy in my first test. See the graph below of the free storage space during a second test where I intentionally waited a bit before running VACUUM FULL
.
Should I (still) create a down migration file that runs last and runs a VACUUM FULL
query to free up storage space? I suspect no downsides since all my objects and data are gone. And autovacuum will do it anyway within minutes.
Best Answer
Other than taking time and resources to run vacuum full will do no harm.
The autovacuum process will eventually trim empty tables. but tables that are merely sparse will continue to consume disk space until a vacuum full.