Joe
Joe

Reputation: 13

What would happen if 2 or more people attempt to update the same MySQL table at the same time?

What if an application has thousands of simultaneous users at any given time and throughout the course of it's existence 2 or more users perform an action that causes the app to update a database table due to a request performed at the exact same time (to the nano second).

What would happen, would MySQL simply put one over the other and the change will reflect the last or would the world come to an end due to some sort of internal conflict error?

Upvotes: 1

Views: 675

Answers (2)

user330315
user330315

Reputation:

It depends on the storage engine.

MyISAM will not allow concurrent updates to the same table even if different rows are affected because MyISAM always locks the whole table.

Whereas InnoDB will allow to update two different rows concurrently as it does row level locking.

Upvotes: 0

Oded
Oded

Reputation: 499262

It completely depends on how the queries have been structured and what concurrency controls you have used.

I suggest reading this for a good overview of the issues and possible solutions.

Upvotes: 1

Related Questions