- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Multiversion Timestamp Ordering
Multiversion Timestamp Ordering (MVTO) is a popular concurrency control technique used in database management systems (DBMSs). MVTO allows multiple versions of a data item to coexist at the same time, providing high concurrency and data consistency while preventing conflicts and deadlocks.
In this article, we will discuss the definition and components of MVTO, as well as how it works.
Multiversion Timestamp Ordering (MVTO)
In MVTO, each version of the data item has a unique timestamp associated with it. Transactions that access the data item are assigned timestamps as well.
There are three components of MVTO: timestamps, versions, and ordering −
Timestamps are assigned to transactions and data item versions to determine the order of operations.
Versions are created when a data item is modified, and each version has a unique timestamp.
Ordering ensures that transactions only access the appropriate version of the data item based on their timestamps.
How MVTO works
There are two types of read operations. These are read-only and read-write transactions.
A read-only transaction can access any version of a data item. He was present at the time of initiation of the transaction.
Read-write transactions can only access the latest version of the data item. That version was created before the transaction was committed.
II. Write operation
There are three types of write operations: insertion, deletion, and update.
In case of data item insertion. It is given a new timestamp.
In case of deletion of a data item. It is marked as deleted but not physically removed from the database.
In the case of a data item update. A new version with a new timestamp is created, and the old version is marked as deleted.
Multiversion timestamp ordering technique for serializability
In the Multiversion timestamp ordering technique, unique timestamps are assigned to each transaction and multiple versions are maintained for each data item. The technique ensures serializability by following two rules.
If a transaction T issues a Read(X) request, and Read_TS(Xi) < TS(T), the system returns the value of Xi to the transaction T and updates Read_TS(Xi) to TS(T).
If a transaction T issues a Write(X) request and TS(T) < Read_TS(X), the system aborts transaction T. If TS(T) = Write_TS(X), the system overwrites the contents of X; if TS(T) > Write_TS(X), it creates a new version of X.
Maintained fields for each version of a data item −
The value of the version.
Read_TS(Xi): The read timestamp of Xi is the largest timestamp of any transaction that successfully reads version Xi.
Write_TS(Xi): The write timestamp of Xi is the largest timestamp of any transaction that successfully writes version Xi.
Consider the following schedule with Transactions T1 and T2, where T1 has a timestamp of 5 and T2 has a timestamp of 10.
Initially, the state of data item X is X0 and Read_TS(X0) = Write_TS(X0) = 0.
T1 performs Read(X), reads the value of X0, and sets Read_TS(X0) = TS(T1) = 5.
T1 performs Write(X), creates a new version X1 and sets Read_TS(X1) = Write_TS(X1) = TS(T1) = 5.
T2 performs Read(X), reads the value of X1, and sets Read_TS(X1) = TS(T2) = 10.
T2 performs Write(X), creates a new version X2 and sets Read_TS(X2) = Write_TS(X2) = TS(T2) = 10.
T1 performs Read(X), reads X1, and the read is successful.
T1 performs Write(X), but since T2 has already read X1, the system aborts T1.
The abort of T1 cascades into T2, and T2 also aborts.
Flowchart for Multiversion Timestamp Ordering
Advantages of Disadvantages of MVTO
Here are the advantages and disadvantages of Multiversion Timestamp Ordering (MVTO) in points −
Preventing conflicts and deadlocks
Support for long-running transactions
Increased computational complexity
In conclusion, Multiversion Timestamp Ordering is a concurrency control technique. It allows for multiple versions of a data item to be stored and used by transactions. Each transaction is assigned a unique timestamp. Each version of a data item, the system maintains the value, read timestamp, and write timestamp.
By allowing multiple versions of a data item to be stored, Multiversion Timestamp Ordering avoids unnecessary aborts of transactions. It reduces contention for the same version of a data item. But, it also requires more storage space and may lead to increased overhead due to the maintenance of multiple versions.
Kickstart Your Career
Get certified by completing the courseGet Started