title: Deadlock on indexed view
body: <p>I have been pulling my hair on this deadlock:</p>
  
  <p><img src="https://i.stack.imgur.com/ZpVY5.png" alt="Deadlock"></p>
  
  <p>[<a href="https://i.stack.imgur.com/ZpVY5.png" rel="nofollow noreferrer">Enlarge</a>]</p>
  
  <p>IX_OrderAmounts is an indexed view doing aggregations on the Amount table. The transaction on the left (Repeatable read - although same happens with Read commited) only inserts a single row in the Amount table. The transaction on the right (Read committed) updates a few rows (2 - 3 rows) from the Amount table (all in one UPDATE statement).</p>
  
  <p>Now what I don't get is why the transaction on the left, which only needs to insert a row, needs to acquire a second update lock.</p>
  
  <p>Because the deadlock is on the indexed view that I don't update directly, I can't really use SQL hints (or at least I don't know how).</p>
  
  <p>How can I resolve this deadlock?</p>