Zend certified PHP/Magento developer

[Question] Avoiding deadlocks

Hello,

Currently in a project we came to debate one thing about deadlocks. We have a table used by thousands of clients.

Lets say for example a table “documents”, where each client has their own documents. The documents can be up to 100 thousand per client.

Lets say that 3 clients update all their documents at the same time. If each client has their own documents, and the process of update is “select * from documents” and then for each result “update documents were document_id = x”, how can a deadlock happen in this situation?

What I’m said is that when we update for example the rows with id 2 and 30, all the lines between are locked in the database.

submitted by /u/RetronWarz
[link] [comments]