Skip to main content

Posts

Showing posts from June, 2021

Deals You Can't Miss

1 Year Subscription

NOLOCK in SQL Server ain't your friend

If you are in a team that is obsessed with NOLOCK hints to your SQL queries, because you think it is faster and an all weather reliable friend, this post is for you to help you understand why you should avoid it (almost always) for it is not your friend.  NOLOCK in SQL Server is often abused as if it is the magical way to speed up read queries. It is unfortunate that teams forget that "there is NO Free Lunch". Every action is trading off one thing for the other and so when you take an action, be aware of what you are trading to give to get something. The Exceptional Circumstances You Can Use NOLOCK When you are querying live DB for some Reporting, where some bad data doesn't alter the overall aggregate numbers that you compute. When you are using WITH (NOLOCK) for SELECT query in reporting database where data are already written and committed. When you are querying a live production DB to take a peak into it and not use the result as a source of truth, knowing that it mig