What is lock escalation, why does it happen, and how can it hurt concurrency?
Answer
Lock escalation is when a database replaces many fine-grained locks, such as thousands of row or page locks held by one statement, with a single coarse lock on the whole table (or partition). It happens to save the memory and overhead of tracking each lock individually. The downside is that a table lock blocks other sessions that only wanted to touch unrelated rows, so one large update can suddenly freeze an entire table.
Why databases escalate
Every lock held in a lock manager costs memory and CPU. A single statement updating two million rows would need two million row locks. To stay within memory limits, some engines trade granularity for efficiency.
In SQL Server, the best-known example:
Escalation is attempted when a single statement acquires roughly 5,000 locks on one table or index, or when lock memory crosses configured thresholds.
Row or page locks escalate directly to a table lock (or a partition lock if LOCK_ESCALATION = AUTO is set on a partitioned table). They never escalate from row to page.
If another session holds a conflicting lock, the escalation attempt fails and SQL Server keeps the fine-grained locks and retries later.
Db2 also escalates when its lock list fills (configured by LOCKLIST and MAXLOCKS).
Databases that do not escalate row locks
PostgreSQL stores row locks in the row itself (the tuple header), not in a shared lock table, so there is no memory pressure to escalate. It does consolidate predicate locks under SERIALIZABLE into page or relation level when there are too many, which can increase false serialization failures.
Oracle stores row locks in the data blocks and never escalates.
MySQL InnoDB uses a compact bitmap per page for record locks and does not escalate.
Knowing this is useful: "lock escalation" is mainly a SQL Server and Db2 concern.
How it hurts in practice
A nightly job runs UPDATE orders SET status = 'ARCHIVED' WHERE created_at < '2025-01-01' touching 800,000 rows. The engine escalates to a table lock. Every API request that inserts or updates an order now waits, timeouts spike, and dashboards show "database slow" even though only one statement is running.
How to prevent or reduce it
Batch large modifications into chunks below the threshold (for example 2,000 to 4,000 rows per transaction in SQL Server).
Add indexes so statements lock only the rows they need instead of scanning and locking many.
Keep transactions short; locks are held until commit.
Use row versioning (READ_COMMITTED_SNAPSHOT in SQL Server) so readers do not take shared locks.
Partition large tables and set LOCK_ESCALATION = AUTO so escalation stops at a partition.
LOCK_ESCALATION = DISABLE exists but can exhaust lock memory, so use it carefully.
How lock escalation unfolds in SQL Server. One large statement goes from row locks to a table lock that blocks everyone.
Large UPDATE starts: Statement begins locking rows one by one.
Lock count passes about 5,000: Engine decides tracking rows is too costly.
Escalate to table lock: Row locks released, one exclusive table lock held.
Other sessions block: Unrelated inserts and updates wait.
Commit releases the lock: Queued requests finally proceed.
Code examples
Batching updates to stay below the escalation threshold (T-SQL)
DECLARE @rows INT = 1;
WHILE @rows > 0
BEGIN
BEGIN TRANSACTION;
UPDATE TOP (3000) dbo.orders
SET status = 'ARCHIVED'
WHERE created_at < '2025-01-01'
AND status <> 'ARCHIVED';
SET @rows = @@ROWCOUNT;
COMMIT;
END;
-- Allow escalation to stop at partition level on a partitioned table
ALTER TABLE dbo.orders SET (LOCK_ESCALATION = AUTO);
Each batch commits after 3,000 rows, so no single statement crosses the threshold and other sessions keep working between batches.
Key points
Lock escalation converts many row or page locks into one table or partition lock.
It saves lock memory but reduces concurrency sharply.
SQL Server attempts it around 5,000 locks per statement on one object, or under lock memory pressure.
PostgreSQL, Oracle and InnoDB do not escalate row locks.
Prevent it with batching, good indexes, short transactions and row versioning.
Common follow-up questions
Why does PostgreSQL not need lock escalation?
What is the difference between lock escalation and a deadlock?
How does READ_COMMITTED_SNAPSHOT reduce blocking?
How would you diagnose blocking caused by escalation in production?
Interview tips
Explain the memory vs concurrency trade-off; that is the heart of the question.
Note that not every database escalates; naming PostgreSQL and Oracle as counterexamples shows depth.
Offer batching as the practical fix with a concrete batch size.