Concurrency control methods like locking prevent data inconsistencies when multiple transactions access the same data concurrently. There are two main concurrency control techniques: single-version concurrency control (SVCC) and multi-version concurrency control (MVCC). SVCC uses locking and only maintains a single version of each record, while MVCC creates new versions of records during updates to allow concurrent read and write operations without locking. MVCC has better performance for environments with frequent transactions.
How to Track Employee Performance A Comprehensive Guide.pdf
[Altibase] 6 what is the mvcc
1. Concurrency Control
Method that prevent the inconsistency, loss and the changes while
processing multiple transactions.
Lock is provided for concurrency control to let multiple transactions change
different data from a same table while they are not affecting each other.
Table
2. Concurrency
Multiple users or sessions accessing same data at same time
Consistency
Restricting multiple users or sessions accessing same data at same time
Concurrency
Consistency
3. Transaction Lock
Prevents modifying same data in a multi-user environment
Automatically grants the lock for DML and DDL
To provide maximum consistency
Two different locks: Row level lock & Table level lock
Trasaction1
UPDATE emp
SET salary = 1,000,000
WHERE id = ‘alti100’ Trasaction2
UPDATE emp
SET salary = 2,000,000
WHERE id = ‘alti100’
Lock granted
Waiting……
4. SVCC vs. MVCC
Methods for controlling simultaneous read / modify operations on the same
records
SVCC (Single-Version Concurrency Control)
With this method, only one version (or “image”) of a record exists.
Even search operations can affect other transactions.
MVCC (Multi-Version Concurrency Control)
With this technique, when a record is changed, the original version of the
record is maintained and unchanged. A new changed version of the record
is created, so that even if one transaction is performing an operation on a
record, it will have no effect on another transaction that reads the same
record.
5. SVCC
Because a record is locked when it is modified, conflicts can occur
between read and modifying operations, thus there is a high possibility of
reduced performance in environments characterized by frequent
transactions.
SVCC
Client
UPDATE t1
SET c1=20
WHERE c1=10
10 120
Client
SELECT c1 FROM t1
Commit
Commit Success
Exclusive Mode Lock
Waiting…. Output Displayed
6. MVCC
When a record is modified, it is locked and a new version of the record is
created, so conflicts do not occur between read and modifying operations.
Good performance is guaranteed, even in environments characterized by
frequent transactions.
Client
UPDATE t1
SET c1=20
WHERE c1=10
10 1
Client
SELECT c1 FROM t1
Commit
Commit Success
Exclusive Mode Lock
Output(10)
10 120
SELECT c1 FROM t1
Output(20)
7. Out-place MVCC is used for Memory tables
New versions of records are saved together with old versions every time
an UPDATE operation occurs.
New version of a record is saved in the data page with a different Row ID.
When a transaction is committed, only the most recent version of the
record is maintained, the rest are deleted by the garbage collector
(Memory Ager).
Out-place (RID Change)
Data Page
Client
UPDATE t1
SET c1=20
WHERE c1=10
101
2 1020
Client
SELECT c1 FROM t1
Commit
Commit Success
Output displayed(10)Output displayed(20)
Memory
Ager
8. In-place MVCC is used for disk tables
In in-place MVCC, when an UPDATE operation occurs, the contents of
modified columns that belong to the original record are written as undo log
records to the Undo tablespace, and the modified values are written to the
location of the original record.
In-place (RID Maintained)
Data Page Undo Area
201 10
Client
UPDATE t1
SET c1=20
WHERE c1=10
Client
SELECT c1 FROM t1
Commit
Commit Success
Output displayed(10)Output displayed(20)
1 10