July 25, 2012 at 3:33 am
Hi,
Today i found something interesting point on lock escalation (from the concurrency prospective).
If the query is updating the rows, and the no.of rows updated by query is less than 5000 then there is no escalation ( from row to table level)
"When a query consumes more than 5000 locks per index / heap."
why this limitation exists in sql server?
Thanks
🙂
July 25, 2012 at 7:53 am
It's a trade-off between performance and concurrency.
Staying at row-level locking allows other operations to perform on parts of the table not affected by the current query, at the cost of the overhead of obtaining and holding multiple row-level locks.
Escalation to table-level minimises this overhead by only holding one lock on the table, at the cost that other operations on the table must wait until the current query has completed and released the table lock.
July 25, 2012 at 8:05 am
Locks take memory. Lots of locks take lots of memory and there's a point where it's just too expensive to hold and check lots and lots and lots of row or page locks.
If SQL didn't escalate it would be perfectly possible for the memory required by the locks to exceed the available memory on the server and when that happens no queries can run at all.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 25, 2012 at 9:20 am
Hi Gail
Just a quick one - Does lock escalation also depend upon the size of the table? Or it only depends upon the memory buffer allocated for holding locks?
Thanks in anticipation.
- Lokesh
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
July 25, 2012 at 10:18 am
No and no. 5000 locks (there is a memory threshold, but you shouldn't hit that unless escalation's been disabled)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 25, 2012 at 10:36 am
Ohk..got it now. Thanks
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
July 25, 2012 at 10:42 pm
Apart from 5000 locks threshold, in 32Bit, Lock escalation will happen if 24%of memory is used up by database engine,excluding AWE. In 64, its the over all memory by database engine.
July 25, 2012 at 11:03 pm
Hi,
Thanks for more explanation,
Here memory means the RAM size right? If i have more memory then this limitation will be exceeded (more than 5000 locks).
My question was,
Why there is a limitation 5000 locks?
Is there any specific reason, on which base sql server is restricting this number?
Thanks,
🙂
July 26, 2012 at 2:43 am
SQL* (7/25/2012)
Here memory means the RAM size right? If i have more memory then this limitation will be exceeded (more than 5000 locks).
Yes, memory=RAM in this case. No, 5000 locks (on a single index or table).
The memory threshold allows for escalation at less than 5000 locks.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 26, 2012 at 11:31 pm
Thank you,
My question was,
Why there is a limitation 5000 locks?
Is there any specific reason, on which base sql server is restricting this number?
Can any one tell the reason behind this limitation?
Thanks,
🙂
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply