Postgres is ACID compliant, which stands for Atomicity, Consistency, Isolation, and Durability. What this means is that, in case of system failure, Postgres won’t lose or miscommunicate data, even if there are many changes made in a single transaction.
To achieve this, it will:
First, write all inserts, updates, and deletes to the Write Ahead Log (WAL).
Write WAL changes to data files when a CHECKPOINT
occurs.
Mark tuples dirty when they are updated or deleted. For updates, it rewrites the entire row as a clean tuple.
Run vacuum processes asynchronously to clean up dirty tuples by marking the space in the file as reusable.
Write new changes to data files over the top of reusable space during the next CHECKPOINT
.
In the next section, we’ll go into detail about the WAL.