• Ivan R. - Sunday, February 25, 2018 7:21 PM

    agree that the more time a query has to run, it increases the chance it could deadlock with something else. this might be the most generic correlation to deadlock.

    on the other hand, reducing the time a query takes will generally be the way to reduce the chances of a deadlock.

    hope this helps
    ivan r.

    Reducing the time a query takes to execute will not get rid of the deadlock issue.  Deadlocks are a result of resource contention (very generally described) at runtime and can only be solved by programmatically altering the query to eliminate that contention.  If you are experiencing Deadlocks as show by the trace flag then you need to hunt down the rpogrammtic cause for it.

    What you are talking with regards to execution times are related to exclusive locks implemented during DML operations.  You "could" resolve the issue by using a NOLOCK hint but this is definately not advisable because you could end up with inconsistent results due to the reading of, in end effect, inconsistent data.  This is similat to having a database isolation level of Read Uncommitted.

    Changing the isolation level to "Read Committed Snapshot" helps often by using versioning to reduce the problems associated with exclusive locking.  You will need to be careful though because in some cases the version store could become bloated.