Effects of Isolation Levels Select Queries with readpast

Readpast locking will have different effects in the select command based on the transaction isolation level.

Readpast locking is designed to be used at transaction isolation level 1 or 2.

Session-Level Transaction Isolation Levels and readpast

This table that shows the effects of readpast on a table in a select command on data-only-locked tables:

Session Isolation Level

Effects

0, read uncommitted (dirty reads)

readpast is ignored, and rows containing uncommitted transactions are returned to the user. A warning message prints.

1, read committed

Rows or pages with incompatible locks are skipped; no locks are held on the rows or pages read.

2, repeatable read

Rows or pages with incompatible locks skipped; shared locks are held on all rows or pages that are read until the end of the statement or transaction.

3, serializable

readpast is ignored, and the command executes at level 3. The command blocks on any rows or pages with incompatible locks.

Query-Level Isolation Levels and readpast

If select commands that specify readpast also include any of the following clauses, the commands fail and display error messages.

The commands fail when:
  • The at isolation clause, specifying 0 or read uncommitted

  • The at isolation clause, specifying 3 or serializable

  • The holdlock keyword on the same table

If a select query that specifies readpast also specifies at isolation 2 or at isolation repeatable read, shared locks are held on the readpast table or tables until the statement or transaction completes.

readtext commands that include readpast and that specify at isolation read uncommitted automatically run at isolation level 0 after issuing a warning message.