I am trying to get my table to use row locks. I have already disabled lock escalation. The isolation level is READ_COMMITTED_SNAPSHOT
alter table <TABLE_NAME> SET (LOCK_ESCALATION=DISABLE)
go
alter index <INDEX_NAME> ON <TABLE_NAME> SET (ALLOW_PAGE_LOCKS=OFF)
go
It's still not working after setting this.
Do I need to rebuild my table in order for it to not use page locking?
Best Answer
The setting to disable page locking applies per index, so applying this change to the clustered index only affects execution plans that access the data via that index. If there are nonclustered indexes on the table, you may have to disable page locking for them as well. The following script demonstrates this:
Using the clustered index as the access method:
Using the nonclustered index:
Note that disabling page locking can have unexpected side-effects, such as preventing index reorganization (since this process works at the page level):