NOLOCK inside view vs. NOLOCK in selection from view

  • Is there any difference (locks, performance) between using NOLOCK hint inside view (for each table used in view) and using NOLOCK hint when selecting from view (withou hints inside)?

  • Not that I know of. Both can mess up your data in the same ways, so it's a pretty safe bet that both will have the same effect on performance.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Assuming you're not talking about a materialized view, then there should be no difference whatsoever, since during the compile phase of the outer query, the reference to the view is replaced by the text of the view, and then the "new" outer query is compiled on its own.

    And - I fully agree with all of the caveats brought up by Gsquared.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Of course, I use this hint only when I don't need accurate data - in my case this is acceptable for some reports.

    Thanks for replies.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply