Postgresql – What are the advanvates and disadvantages of vacuum in postgresql

postgresqlvacuum

I'm new to PostgreSQL, I know about the concept of vacuum in database.

But I want to know the major advantages and disadvantages of vacuuming process.
Also I want to know:

  1. What happen if I access the table while vacuuming full database?
  2. Whether it will affect the table, or cause data loss?

Best Answer

Vacuum is an inherent part of Postgres due to the MVCC model - you don't have much choice, it's there.

As for vacuum full - it rewrites the table and takes an exclusive lock in the process- you won't be able to access your table.

It sounds bad but recent releases reduced the need for vacuum full dramatically. Frequent regular vacuum (using the autovacuum for example) should be enough in most cases. Just make sure to monitor your vacuuming and DB for bloat.