A transaction in DBMS is a sequence of operations performed as a single logical unit of work. When multiple transactions execute simultaneously, it is called concurrency. Modern database systems support concurrent transactions to improve performance, throughput, and system utilization.
However, concurrency also introduces several problems related to data consistency, which DBMS handles through concurrency control techniques.
Concurrent transactions are transactions executed at the same time in a multi-user database environment.
DBMS allows concurrent execution to:
✔ Improve system performance
✔ Reduce waiting time
✔ Utilize CPU and I/O efficiently
✔ Support multiple users simultaneously
Higher Throughput – More transactions complete in less time.
Reduced Response Time – Users do not wait for others to finish.
Better Resource Utilization – CPU and disk remain busy.
Scalability – Supports large numbers of users and applications.
Without proper control, concurrency can lead to inconsistency. The main problems are:
A transaction reads uncommitted data written by another transaction.
Example:
T1 updates balance → T2 reads updated value → T1 rolls back.
A transaction reads the same data twice and gets different values because another transaction modified it in between.
Two transactions update the same data; one update overwrites the other.
A transaction re-executes a query and finds new rows inserted by another transaction.
A transaction reads several values while another transaction is updating them.
DBMS uses Concurrency Control Protocols to maintain consistency.
Locks prevent two transactions from accessing the same data simultaneously.
Shared Lock (S-lock): For reading
Exclusive Lock (X-lock): For writing
Two-Phase Locking (2PL)
Strict Two-Phase Locking
Rigorous 2PL
These ensure serializability and recoverability.
Each transaction gets a timestamp.
Operations are ordered by timestamps to avoid conflicts.
Assumes conflicts are rare.
Validates transactions before commit.
Keeps multiple versions of data.
Used in PostgreSQL, MySQL InnoDB, Oracle.
Benefits:
✔ No blocking reads
✔ High performance
DBMS defines isolation levels to balance consistency and performance:
| Isolation Level | Problems Prevented |
|---|---|
| Read Uncommitted | — |
| Read Committed | Dirty Reads |
| Repeatable Read | Dirty + Unrepeatable Read |
| Serializable | All problems prevented |
To ensure correctness, concurrent transactions must be serializable, meaning the result is the same as if transactions ran one after another.
Types:
Conflict Serializability
View Serializability
Concurrent transactions are essential for multi-user DBMS environments to improve performance and throughput. However, concurrency can introduce several anomalies, which are managed using locking, timestamp ordering, MVCC, and isolation levels. Understanding concurrency and its control mechanisms ensures data correctness, consistency, and reliability in database systems.
Take quizzes related to this topic and see where you stand!
Start Quiz Now