A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Concurrency Control in Databases

College Depth 100 in the knowledge graph ☐ I know this ☆ Set as goal
16topics build on this
405prerequisites beneath it
See this on the map →
ACID PropertiesMutual Exclusion and Locks+1 more→→Isolation Level: READ COMMITTEDIsolation Level: READ UNCOMMITTED (Dirty Reads)+6 more
concurrency control isolation levels dirty read phantom read MVCC serializability

Core Idea

Concurrency control ensures that concurrent transactions produce results equivalent to some serial execution, preventing read anomalies: dirty reads (reading uncommitted data), non-repeatable reads (a row changes between two reads in the same transaction), and phantom reads (new rows matching a predicate appear between reads). The SQL standard defines four isolation levels — READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE — that progressively prevent more anomalies at increasing performance cost. Multi-Version Concurrency Control (MVCC) allows readers to see a consistent snapshot without blocking writers by maintaining multiple versions of each row.

How It's Best Learned

Reproduce read anomalies experimentally with two database sessions: start a transaction in one, modify data, then read from the other before committing. Switch isolation levels and observe which anomalies are prevented.

Common Misconceptions

Explainer

When two transactions execute against the same database simultaneously, their reads and writes can interleave in ways that produce surprising results — results that would never occur if the transactions ran one after the other. Concurrency control defines how the database manages these interactions. The goal is serializability: the outcome of concurrent transactions should be equivalent to *some* serial ordering, even though they actually ran in parallel.

Three classic read anomalies mark the failure modes. A dirty read occurs when transaction A reads data that transaction B has written but not yet committed — if B rolls back, A has read data that never officially existed. A non-repeatable read occurs when A reads a row, B updates and commits it, and A reads it again to get a different value within the same transaction. A phantom read is similar but involves rows disappearing or appearing: A queries for all rows matching a predicate, B inserts a matching row and commits, and A's second query finds a different set of rows.

The SQL standard defines four isolation levels that progressively prevent more anomalies. READ UNCOMMITTED allows all three anomalies (rarely used). READ COMMITTED (the default in PostgreSQL and Oracle) prevents dirty reads. REPEATABLE READ additionally prevents non-repeatable reads. SERIALIZABLE prevents all three, including phantom reads, at the cost of reduced throughput and potential transaction aborts. Choosing an isolation level is always a tradeoff between data consistency and performance.

MVCC (Multi-Version Concurrency Control) is the mechanism most modern databases use to implement these guarantees efficiently. Instead of locking rows so readers and writers block each other, MVCC maintains multiple timestamped versions of each row. When a transaction starts, it receives a snapshot timestamp and reads whichever row version was current at that moment. Writers create new versions without overwriting old ones. Because readers and writers operate on different versions, they never block each other — a long-running read query does not stall writes, and writes do not interrupt reads.

Understanding concurrency control ties directly back to the Isolation property in ACID: each transaction should appear to execute in isolation from others. The isolation levels are essentially a dial that trades more isolation for more performance. Most applications run at READ COMMITTED and handle residual anomalies at the application level, but correctness-critical operations (bank transfers, inventory updates) require REPEATABLE READ or SERIALIZABLE to avoid subtle bugs.

Practice Questions 3 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Kernel Architecture and OS Structure → System Calls and User/Kernel Mode → Processes and the Process Control Block → Process Creation: fork() and exec() → Process Termination and Resource Cleanup → Process States and State Transitions → Threads and Concurrency → The Critical Section Problem and Race Conditions → Mutual Exclusion and Locks → Concurrency Control in Databases

Longest path: 101 steps · 405 total prerequisite topics

Prerequisites (3)

Leads To (8)