Solved

If I don't use Nolock on a select statement...

Posted on 2013-06-25
1
284 Views
Last Modified: 2013-06-25
Can I lock up data?
0
Comment
Question by:patriotpacer
1 Comment
 
LVL 20

Accepted Solution

by:
dsacker earned 500 total points
ID: 39276151
Potentially, yes. Within a pristine design, usually no.

For instance, if you have a query without the NOLOCK that does lengthy table scans, against fields that are not indexed, etc., you could lock the table. If others are trying to update that table, they could be in a wait state until your query finishes.

If you have good indexing, and tailor your queries accordingly, even though some deadlocking may still occur, the query is usually very quick and will use indexing efficiently. Very little deadlocking will occur.

In general, WITH (NOLOCK) will prevent locking the table, if you don't mind having the potential of "dirty" reads. I know programming shops where it is still an offense subject to termination if queries do not include the WITH (NOLOCK).
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL replication over high latency link 10 61
tempdb log keep growing 7 34
Is there a better way to combine two queries 7 27
SQL Activity Monitor detail 2 28
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question