Sub topic 3
Serial and Concurrent Schedules
Assume you know basic tables, rows, SELECT, and UPDATE statements. You should also be comfortable with directed graphs and the idea that a transaction is a unit of database work.
What a schedule records
A schedule is the order in which a database system performs the operations of several transactions. It records reads, writes, commits, and aborts while preserving the original order inside each transaction.
For example, let:
T1: readA, writeA, commitT2: readB, writeB, commit
A schedule can be written as a sequence:
r1(A), w1(A), c1, r2(B), w2(B), c2Here, r1(A) means that transaction T1 reads item A. The notation w2(B) means that T2 writes item B. A commit is written as c1 or c2.
A valid schedule may interleave transactions, but it cannot change the order of operations within one transaction. If T1 must read before it writes, a schedule cannot place w1(A) before r1(A).
Serial schedules
A serial schedule runs one complete transaction before starting another. There is no interleaving.
r1(A), w1(A), c1, r2(B), w2(B), c2This schedule runs T1 first and T2 second. The reverse order is also serial:
r2(B), w2(B), c2, r1(A), w1(A), c1Serial execution is easy to reason about because each transaction sees a stable database state while it runs. Its main disadvantage is lower concurrency. A transaction waiting for disk, a network response, or user input can prevent other transactions from using the database.
Concurrent schedules
A concurrent schedule interleaves operations from multiple transactions:
r1(A), r2(B), w1(A), w2(B), c1, c2This schedule is concurrent because operations from T1 and T2 are mixed. It can improve throughput because one transaction can make progress while another waits.
Concurrency is safe when the result is equivalent to a correct serial execution. The order of operations matters especially when transactions access the same item. Operations on different items often can be interleaved without changing the result, but later analysis must check the actual reads and writes.
| Schedule type | Transaction operations | Main property |
|---|---|---|
| Serial | One transaction finishes before the next begins | Simple but less concurrent |
| Concurrent | Operations from transactions are interleaved | Faster, but requires control |
A worked comparison
Suppose A = 100.
T1transfers 10 fromA: readA, subtract 10, writeA.T2transfers 20 fromA: readA, subtract 20, writeA.
A serial execution produces 70. In an unsafe interleaving, both transactions can read 100 before either writes. T1 then writes 90, and T2 writes 80. The final value is 80, so the effect of T1 has disappeared.
The schedule itself is not automatically wrong because it is concurrent. The problem is that the interleaving does not preserve the intended transaction behavior.
Exercise
Is r1(A), r2(B), w1(A), c1, w2(B), c2 serial or concurrent? Does it preserve the order inside each transaction?
Show answer
It is concurrent because the operations are interleaved. Yes, it preserves each transaction's internal order: T1 reads before writing, and T2 reads before writing.