Allpages locking

Allpages locking locks data pages and index pages. When a query updates a value in a row in an allpages-locked table, the data page is locked with an exclusive lock. Any index pages affected by the update are also locked with exclusive locks. These locks are transactional, meaning that they are held until the end of the transaction.

Figure 1-1 shows the locks acquired on data pages and indexes while a new row is being inserted into an allpages-locked table.

Figure 1-1: Locks held during allpages locking

Two images showing locks held at the leaf-level, one of the authors first name, another on the authors last name.

In many cases, concurrency problems that result from allpages locking arise from the index page locks, rather than the locks on the data pages themselves. Data pages have longer rows than indexes, and often have a small number of rows per page. If index keys are short, an index page can store between 100 and 200 keys. An exclusive lock on an index page can block other users who need to access any of the rows referenced by the index page, a far greater number of rows than on a locked data page.