PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE

VACUUM, VACUUM FULL and ANALYZE: This is very basic and important command of PostgreSQL.
We require to execute this command frequently because MVCC nature of PostgreSQL.
You can visit this article for more on MVCC.

In this post, I am providing very quick and short on this.


VACUUM reclaims storage occupied by dead tuples. In MCVV architecture tuples that are deleted which are not physically removed from their table. It presents in a disk until a VACUUM is done.
If your table frequently update, you require to execute VACUUM periodically.
VACUUM does not require an exclusive lock on the table.


Whatever space reclaims by VACUUM that space require to use for next storage because all that space require to use for next storage because all that space is scattered in a disk.
VACUUM FULL rewrites the entire table with data into new space without any extra space and release all scattered space of an old table.
VACUUM FULL requires an exclusive lock on the table, but after VACUUM FULL you will get 30% to 40% better performance of the table.


After VACUUM or VACUUM FULL this command is also required to execute.
ANALYZE updates all require statistics used by planner. The Planner is responsible to execute query with the best efficient way.
You can also execute VACUUM ANALYZE for both operations.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

2 Comments on "PostgreSQL: Short note on VACUUM, VACUUM FULL and ANALYZE"

Notify of

Sort by:   newest | oldest | most voted
Advokatska Kancelarija
Advokatska Kancelarija
10 months 18 days ago

A fascinating discussion is worth comment. I think that you need to write more on this subject, it
might not be a taboo subject but generally people do
nnot speak about such issues. To the next! Kind regards!!

2 months 5 days ago

Very nice post, really help me to understand better the differences between vaccums.

Reading others posts and they are prety cool.