On the other hand, there are two more aspects that can help.
1) Indexes and indexes used by SQL. The indexing strategy used in the tables affects the number of rows. If you make data changes using a unique index, you can reduce the likelihood of locks.
One algorithm - of course, it will not work in all cases. Using NOLOCK is intended, not globally.
The "old" way: UPDATE dbo.change_table SET somecol = newval WHERE non_unique_value = 'something' The "new" way: INSERT INTO
2) Transaction Duration The longer the transaction is open, the more likely it is to dispute. If there is a way to reduce the time that records remain locked, you can reduce the likelihood of a deadlock. For example, execute as many SELECT statements (for example, lookup) at the beginning of the code, and not perform INSERT or UPDATE, then find, then INSERT, and then another search. Here you can use the NOLOCK hint for SELECT on "static" tables that do not change, reducing the blocking of the "footprint" code.
source share