Sql-server – why locks a table will improve performance during transaction

sql server

I just started to read about table lock in SQL (from this page)

It saids:

table lock may reduce the overhead of acquiring a large number of row
or page locks and save overall locking time

From my understanding it will prevent other query to access the table I have locked, but why will this improve the performance? Isn't it will slow down over roll queries when there is mutiple user trying to use the table? Can someone explain little bit more?

Best Answer

In a multi-user environment, you'll want to avoid table locks as it is bad for concurrent use and prone to deadlocks.

If you do large bulk DML with lots of updates/deletes in one transaction however, you will avoid the overhead of the database server having to manage locks on the row or page level if you end up modifying a large percentage of the table anyway.