MVCC in PostgreSQL
Accessing the same data at the same time for read and write purposes might cause an inconsistent data state or wrong reads. For example, the reader might get partially written data. The simplest technique for solving this is to lock the reader from reading the data until the writer finishes writing the data. This solution causes a lot of contention, hence the performance penalty, and causes the reader to wait until the writer is done with the job.
In MVCC, when the data is updated, a newer version of the data is created, and the original data is not overwritten. That means there are several versions of data, hence the name multi-version. Each transaction can access a version of the data based on the transaction isolation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access