Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:13:40+00:00 2026-05-27T08:13:40+00:00

I have a process with a Select which takes a long time to finish,

  • 0

I have a process with a Select which takes a long time to finish, on the order of 5 to 10 minutes.
I am currently not using NOLOCK as a hint to the MS SQL database engine.
At the same time we have another process doing updates and inserts into the same database and same tables.
The first process has started, recently to end prematurely with a message

SQLEXCEPTION: Transaction was deadlocked on lock resources with another process and has been chosen as the deadlock victim.

This first process is running at other sites in identical conditions but with smaller databases and thus the select statement in question takes a much shorter period of time (on the order of 30 seconds or so). In these other sites, I don’t get the deadlock message in these other sites. I also did not get this message at the site that is having the problem initially, but, I assume, as the database has grown, I believe I must have crossed some threshold. Here are my questions:

  1. Could the time it takes for a transaction to execute make the associated process more likely to be flagged as a deadlock victim.
  2. If I execute the select with a NOLOCK hint, will this remove the problem?
  3. I suspect that a datetime field that is checked as part of the WHERE clause in the select statement is causing the slow lookup time. Can I create an index based on this field? Is it advisable?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:13:40+00:00Added an answer on May 27, 2026 at 8:13 am

    Q1:Could the time it takes for a transaction to execute make the associated process more likely to be flagged as a deadlock victim.

    No. The SELECT is the victim because it had only read data, therefore the transaction has a lower cost associated with it so is chosen as the victim:

    By default, the Database Engine chooses as the deadlock victim the
    session running the transaction that is least expensive to roll back.
    Alternatively, a user can specify the priority of sessions in a
    deadlock situation using the SET DEADLOCK_PRIORITY statement.
    DEADLOCK_PRIORITY can be set to LOW, NORMAL, or HIGH, or alternatively
    can be set to any integer value in the range (-10 to 10).

    Q2. If I execute the select with a NOLOCK hint, will this remove the problem?

    No. For several reasons:

    • you should first try to eliminate the deadlock properly, by investigating the root cause
    • dirty reads are inconsistent reads.
    • the proper way to specify dirty reads is to use transaction isolation levels
    • there is a much better solution: read committed snapshot.

    Q3. I suspect that a datetime field that is checked as part of the WHERE clause in the select statement is causing the slow lookup time. Can I create an index based on this field? Is it advisable?

    Probably. The cause of the deadlock is almost very likely to be a poorly indexed database.10 minutes queries are acceptable in such narrow conditions, that I’m 100% certain in your case is not acceptable.

    With 99% confidence I declare that your deadlock is cased by a large table scan conflicting with updates. Start by capturing the deadlock graph to analyze the cause. You will very likely have to optimize the schema of your database. Before you do any modification, read this topic Designing Indexes and the sub-articles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mySQL query which takes a long time to process. I am
I have a MySQL UPDATE query which takes a long time to complete. Am
I have a process which finds a list of files to be deleted using
I have an executable file - process.exe - which takes a single file path
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)
I have a process which has a notify method which receives as a parameter
I have written an application (using Delphi 2009) that allows a user to select
I have SQL SELECT query which returns a lot of rows, and I have
I've this query, which works fine except it takes a long while (7 seconds,
Today I have just thrown together this PowerShell script which takes a tab-delimited text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.