SQL Server NOLOCK and joins

前端 未结 3 1924
暖寄归人
暖寄归人 2021-01-29 20:50

Background: I have a performance-critical query I\'d like to run and I don\'t care about dirty reads.

My question is; If I\'m using joins, do I have to specify the NOLOC

3条回答
  •  青春惊慌失措
    2021-01-29 21:24

    I won't address the READ UNCOMMITTED argument, just your original question.

    Yes, you need WITH(NOLOCK) on each table of the join. No, your queries are not the same.

    Try this exercise. Begin a transaction and insert a row into table1 and table2. Don't commit or rollback the transaction yet. At this point your first query will return successfully and include the uncommitted rows; your second query won't return because table2 doesn't have the WITH(NOLOCK) hint on it.

提交回复
热议问题