Get the latest tech news
Exploring the enigma of database vacuuming
Before we discuss what VACUUM does and its implications, we need to understand how data is actually stored on disk. What happens when a tuple is inserted, updated, or deleted? Understanding this will help us understand what VACUUM does, why it’s needed, and its implications.
Performing a plain vacuum operation on a database table does not always require an exclusive lock, except during the Heap Truncating phase. The primary node can monitor ongoing Data Manipulation Language (DML) operations on the table and release the lock if needed. If you have a running job that might update or delete a large number of rows, it is better to disable the TRUNCATE option in the VACUUM operation so that the ACCESS EXCLUSIVE is not acquired, which might impact the production traffic.
Or read this on Hacker News