
Concurrency control refers to the mechanisms used by a DBMS to manage simultaneous execution of transactions in a multi-user environment to ensure:
Concurrency control refers to the mechanisms used by a DBMS to manage simultaneous execution of transactions in a multi-user environment to ensure:
When multiple users or applications access the database at the same time, several problems can occur:
| Problem | Description |
|---|---|
| Lost Update | Two transactions update the same data and the first update is overwritten. |
| Dirty Read | A transaction reads uncommitted data from another transaction. |
| Non-repeatable Read | A transaction reads the same row twice and gets different data. |
| Phantom Read | New rows are added or deleted in a range between two reads. |
Concurrency control techniques can be broadly classified into:
Locks are used to control access to data items. A transaction must acquire a lock before accessing a data item.
| Lock Type | Description |
|---|---|
| Shared Lock (S-lock) | Used for read-only operations. Multiple transactions can hold shared locks. |
| Exclusive Lock (X-lock) | Used for read and write. Only one transaction can hold an exclusive lock at a time. |
A widely used protocol.
Every transaction is assigned a timestamp. Data items have read and write timestamps.
Instead of locking, MVCC maintains multiple versions of data to allow concurrent reads and writes.
| Technique | Uses Locks? | Deadlock Possible? | Ideal For | Drawbacks |
|---|---|---|---|---|
| Lock-Based (2PL) | Yes | Yes | High-conflict environments | Deadlocks |
| Timestamp-Based | No | No | Time-critical systems | High abort rate |
| Optimistic | No | No | Read-heavy systems | Validation overhead |
| MVCC | No | No | Concurrent reads/writes | Storage usage |
Deadlocks occur when two or more transactions wait for each otherβs locks.
| Key Point | Details |
|---|---|
| Goal | Ensure consistent and correct transaction execution |
| Problems Solved | Lost update, dirty read, non-repeatable read |
| Techniques | Lock-based, timestamp-based, optimistic, MVCC |
| Best Practice | Choose based on workload (read-heavy, write-heavy, real-time) |
Be ready to explain each technique, compare them, and identify which one is best suited for a given scenario.
Open this section to view and download past papers
Click on Show Past Papers to load available exam papers.