Recovery Intuition: Change Tracking 📝

💡 The Database Challenge

Scale: Tables have billions of rows, transactions change a tiny subset
Copying entire database for each transaction would be impossibly slow
🎯 Solution: Track only what changes - just like Google Docs and Git!

You Already Know This!

Google Docs Version History

Google Docs version history showing change tracking

Key insight: Google Docs doesn't store 50 complete document copies. It stores the changes between versions.

Git Version Control

Git diff showing line-by-line changes

Key insight: Git doesn't store every file version. Conceptually, it stores diffs - what changed, when, and by whom.


Example Change Tracking in DB 🎫

Let's see how this applies to our ticket resale scenario:

Transaction T56 lifecycle showing commit/abort paths and database states

UNDO/REDO table showing old and new values for transaction T56

Instead of storing complete database snapshots, we track:

📝 Before & After Values

Which rows, which columns
⏰ When it changed: Transaction timing and sequence
🆔 Who changed it: Which transaction made the change

🎯 Recovery Goals

✅ COMMIT: Make changes permanent and visible
❌ ABORT: Undo changes, return to original state
💥 CRASH: Determine what to keep vs. what to discard