Hi:
Would changing (WITH PAGELOCK) to (WITH ROWLOCK) hint in SQL Server 2000 UPDATE/DELETE statements help to reduce concurrent locking? Can UPDATE in general be more granular than a page level lock?
It depends on the scenarios, but a ROWLOCK will only lock that key value, and if there are 10 rows in a page for instance then the system could maintain other ROWLOCK's based on other keys. Whereas, with a PAGELOCK the system would have the page locked that all 10 rows are in and hold it until the lock is released.
The "it depends" means that SQL Server will escalate the locks based on the data and the scenario. If it is holding a ROWLOCK for a transaction and that transaction does more rows, it could escalate the lock type to a PAGELOCK by itself.
I've done a lot of work in medical practices and the problem isn't so much the volume of work causing locking problems as it is the process flow of the work. 2-3 people all trying to get work done for the same patient at the same time. The doctor wants to input notes about the visit, at the same time that the nurse wants to do something for the patient, at the same time that the patient is trying to check out at the front desk.
But the "in general" answer would be "don't provide any hints and let SQL Server manage the locks for you as it usually guesses better based on the data being worked on." We envision a scenario and try to build around that 1 scenario and often make the other situatins worse.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.