If multiple queries to one and the same large table come to SQL Server at the same time, how SQL Server resolves conflicts in this case?
When using LINQ to SQL queries in WPF application for install on many PC’s, working in network with SQL Server database, should I somehow implement mechanism for resolving such issues or am I protected from issues of this kind by SQL Server and LINQ to SQL?
(I don’t mean concurrent operations to the same record, which resolved by using TIMESTAMP field. I mean some queue issue, when the same large table is queried from multiple network stations)
If your queries cause a deadlock, SQL Server has an internal mechanism to deal with it.
If it detects a deadlock situation, it choose a “victim” transaction to be rolled back. The way it chooses the victim is based first on the priority setting of the transaction, and then on the total cost of rolling back each query. The one that costs less to rollback is usually the victim.
You can actually use the
SET DEADLOCK_PRIORITYto control the priority (LOW, MEDIUM or HIGH, or a number between -10 and 10). If you find you’re in this situation though, you should really be putting your effort into reducing deadlocks in the first place.