3 ms·
Interesting, PostgreSQL works just like you said. However MySQL doesn't. I've just tried it, and MySQL blocks the UPDATE until the first transaction (DELETE, I
by adrianmsmith 14y ago
Interesting, PostgreSQL works just like you said.
However MySQL doesn't. I've just tried it, and MySQL blocks the UPDATE until the first transaction (DELETE, INSERT) is finished (like PostgreSQL), but after the commit, the UPDATE statement updates the newly inserted row.
It seems MySQL firstly searches the table for the row and then attempts to acquire a lock on it (thus waits for the DELETE, INSERT to finish, as it's locked the row being DELETEd), and, after the lock has been acquired, searches the table again for rows matching the query in order to perform it.
- jeltz 14y agoInteresting, I did not know this. Did you run MySQL in READ COMMITTED or REPEATABLE READ? And would it matter?