When a transaction acquires too many row/page locks, Microsoft SQL Server may automatically convert them into a table lock.
Example:
Purpose:
Historically SQL Server relies heavily on:
Without escalation:
So escalation is partly a scalability protection mechanism.
Oracle architecture is fundamentally different:
Oracle therefore tracks far fewer locks.
Even very large reads usually:
So table-level escalation is generally unnecessary.
PostgreSQL uses MVCC tuple versioning:
Result:
Modern SQL Server is much more MVCC-capable now:
But internally it still maintains the classic lock manager architecture, so lock escalation still exists.
In Microsoft SQL Server you can control lock escalation at the table level using:
ALTER TABLE table_name
SET (LOCK_ESCALATION = AUTO);
Possible values:
| Option | Meaning |
|---|---|
| TABLE | Escalate to table lock (default) |
| AUTO | Partition-level escalation when possible |
| DISABLE | Try to prevent escalation |
Examples:
ALTER TABLE sales_big
SET (LOCK_ESCALATION = TABLE);
Useful for partitioned tables:
ALTER TABLE sales_big
SET (LOCK_ESCALATION = AUTO);
Instead of locking the whole table, SQL Server may lock only one partition.
ALTER TABLE sales_big
SET (LOCK_ESCALATION = DISABLE);
Important:
SELECT name,
lock_escalation_desc
FROM sys.tables
WHERE name = 'sales_big';
Possible results:
SQL Server also has internal thresholds:
Trace flags sometimes used:
DBCC TRACEON (1211, -1);
or
DBCC TRACEON (1224, -1);
But these are dangerous in production because disabling escalation globally can:
Usually table-level configuration is safer.
Disabling escalation is rarely the real solution.
Usually better solutions are:
Example batching:
WHILE 1=1
BEGIN
DELETE TOP (10000)
FROM big_table
WHERE create_date < '2024-01-01';
IF @@ROWCOUNT = 0
BREAK;
END
If you disable or avoid lock escalation incorrectly in Microsoft SQL Server and continue running very large transactions, several problems can happen.
Every row/page lock consumes memory.
Example:
Eventually SQL Server may experience:
SQL Server must:
Millions of tiny locks create much more overhead than:
So paradoxically:
Without escalation:
This can produce:
Worst-case scenario:
This is why Microsoft designed escalation as a protection mechanism.