title: How does locking work in INSERT..ON DUPLICATE KEY UPDATE statements?
body: <p>I am encountering deadlocks while trying to update multiple rows (a batch) using INSERT..ON DUPLICATE KEY UPDATE. 
  Does MySQL lock all the rows in one batch or does it lock only the row it is updating at a point of time?</p>