I have a big table which is suffering from Index bloating because a lot of rows are frequently updated. I’m also in the process of deleting a big number of rows.
What would the correct order of executing the following tasks in order to recover disk space?
- Vacuum, mark dead tuples as free for database reuse, doesn’t return
space to system. - Vacuum Full, rewrites table reducing table bloat,
returns space to system. - Reindex, rewrites indexes reducing index
bloat, returns space to system.
Since PostgreSQL 9.0 a
VACUUM FULLshould return disc space optimally (just like CLUSTER does). I quote the release notes for 9.0 from the current manual here:Note that it is not normally necessary or even advisable to run
VACUUM FULL. It may slow down UPDATEs if you remove all wiggle room for HOT updates and such from the data pages.