A deadlock occurs when 2 processes try to use the same data at the same time - as with an equal data requirement. This is most common when there are many update / insert operations (as you described). The database system "selects" one of the transactions as the "winner".
In some cases, deadlocks can be improved or softened by indexing, but only in the case of a choice - a good indexing strategy can increase the efficiency of the selection and increase the efficiency of row locking. However, in the case where the deadlock comes from the insertion associated with the upgrade, indexing will NOT help. Indeed, aggressive indexing can make matters worse, since indexes need to be updated along with inserts or data updates.
How to solve it largely depends on your system and what you are trying to do. You should either minimize insert / update locks, or provide more or faster resources. Binding inserts together and doses them, more procs or RAM (sometimes not always), clustering, splitting tables and data, fine tuning parallelism - all this can be a viable option. And there is no hard and fast rule.
source share