Why Serializability is Important

 

 Why Serializability is Important

  • A schedule is serializable ⇒ correct
  • It behaves like a serial execution (one transaction at a time)

👉 So, serializability = correctness guarantee


⚠️ Serial vs Serializable

Serial Schedule        Serializable Schedule
No interleaving        Interleaving allowed
Very slow ❌        Efficient ✅
Safe ✔        Safe ✔

📌 Key Idea:

  • Serial execution is too slow
  • Serializable execution gives:
    • Correctness
    • Concurrency (performance)

Problem in Practice

❗ Difficulties:

  1. Unpredictable scheduling
    • OS decides execution order
    • Depends on:
      • system load
      • transaction arrival time
      • priorities

👉 So we cannot predict the schedule in advance


  1. Testing after execution is impractical
    • If schedule is not serializable
    • We must:
      • ❌ undo all operations
      • ❌ restart transactions

👉 Very costly and inefficient


Solution: Concurrency Control Protocols

Instead of testing schedules:

👉 DBMS uses protocols (rules) that ensure serializability automatically


📌 Idea:

If every transaction follows rules →
👉 resulting schedule is always serializable


Common Concurrency Control Techniques


1. Two-Phase Locking (2PL)

  • Transactions lock data items
  • Prevents conflicts

Guarantees:

  • ✅ Always serializable

Used in:

  • Most commercial DBMS

2. Timestamp Ordering

  • Each transaction gets a timestamp
  • Operations executed in timestamp order

👉 Ensures correct ordering of conflicts


3. Multiversion Protocols

  • Maintain multiple versions of data
  • Transactions read appropriate version

👉 Improves concurrency


4. Optimistic (Validation) Protocol

  • No strict control during execution
  • At commit time:
    • Check if conflicts occurred

👉 If conflict → rollback


5. Snapshot Isolation

  • Transactions see a snapshot of data
  • Reduces locking overhead

⚠️ Not always perfectly serializable


Continuous Transactions Problem

  • Transactions are continuously entering system
  • No clear start/end of schedule

📌 Solution: Committed Projection

👉 Consider only committed transactions

  • Ignore aborted ones
  • Check serializability of:

    C(S) → committed projection

 Summary

  • Serializability ensures correctness
  • Serial schedules are inefficient
  • Serializable schedules give:
    • ✔ correctness
    • ✔ concurrency

Key Takeaways

  • ❌ Don’t test schedules after execution
  • ✅ Use protocols to guarantee serializability

👉 “Instead of checking if a schedule is correct, DBMS ensures only correct schedules are possible.

Comments

Popular posts from this blog

Database Management Systems DBMS PCCST402 Semester 4 KTU CS 2024 Scheme

Data Models, Schemas and Instances

Introduction to Database Management System -DBMS