Question

In another question a user asks how to force row level locking. The answer that he receives tell them how to force row level locking by altering the table and the indexes. The user that answered the question does also mentions that there can be a side effect of preventing index reorganization.

What i want to know is if someone could explain this side effect further, because our worry is that a table the is inserted into and deleted from a lot, could become slow over time if the side effect of forcing row level locking does what we think it does.

Orginal post:

How to force the use of row locks?

Many thanks in advance

Was it helpful?

Solution

In the referenced link How to force the use of row locks? Paul White demonstrates that index reorganization cannot happen if that index has page locks disabled.

You can, of course, reset Page locking back on before doing a reorganization and then turn it off again afterward:

-- Allow page locks on Index
ALTER INDEX indexname ON tablename SET (ALLOW_PAGE_LOCKS = ON);

For what it is worth, in response to this question https://stackoverflow.com/questions/3114826/is-it-possible-to-force-row-level-locking-in-sql-server Remus Rusanu gives the statement on disabling page locking on an index. But he also comments: "I would never turn this OFF on my database. The solution is always to properly design the schema and the queries so that scans (which are the culprits for escalation) don't occur to start with."

This does not mean that it is wrong to disable page locking, but it points out that there are other ways to work through the problem.

You also might be interested in reading about Lock Escalation (SQL Server 2008 R2 is the most recent document I can find) at: http://technet.microsoft.com/en-us/library/ms184286(v=sql.105).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top