What is Multi-version Concurrency Control in Postgresql?

Asked

Viewed 376 times

4

What is Multi-version Concurrency Control (MVCC) in Postgresql and how it works?

1 answer

6


It’s a technique where nothing is written over it. Every data change is created a new instance of it in another location and updates the references to the new location. This way does not need locking when writing, all readings can access the old data smoothly because it is guaranteed that it is not being changed, other writings do not affect what this transaction is doing.

With the MVCC the isolation and facilitates the consistency and atomicity of ACID and in some cases may facilitate the durability. It is a simple and efficient mechanism if well implemented. Each transaction is completely independent and free of side effects.

You obviously need some form of garbage collector to repurpose the data pages and indexes that are no longer being used by any transaction.

In other words, every database object is immutable, is like the string of many languages, you can create a new one, but you cannot touch the existing one, the new one can be referenced by the same place as before looking like it is the same string.

The technique does not eliminate all need for management. If two transactions are occurring simultaneously there is a case where you only want the old data, but there is a situation where the data already modified in the other transaction needs to be seen, so it has configuration that allows access to the new data.

To give more details would need to explain all the operation of the database, the separation into pages, binary tree, etc., what would not fit here.

Wikipedia.

Presentation by the maintainer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.