Friday, October 1, 2010

Locking in MySQL


As the meaning of the words itself, Locking is locking something. When MySQL is considered its locking databases, tables or raws.There are many concepts in involved in it. The real purpose of locking is to reduce concurrent access of data. Access could be reading or writing.

Reading access could be critical and the worst case is two people updating the same document at the same time, that is writing at the same time. It could be of three categories.
  • Two or more people are reading the same entry
  • One person reading and the other one is writing
  • Two or more people are writing the same entry
The critical situations among those are the second and the third ones where writing at the same time is involved. In normal applications concurrent reading is set to be possible since it does not harm the content if its just reading. But when it comes to writing concurrent wiring possibility will ruin the whole application.

In my sql it does blocking if it is not done explicitely and it is called as implicit locking. And in MySQL SELECT statements and INSERT statement are the ones, which will be locked implicitely.

And when it comes to locking levels, there are two levels where table locking and raw locking are possible. In table locking it locks the whole table concurrent access but in raw level locking it does permit table access but limits the same raw access by two users. And the operations which are blocked would be configurable.

The above described functions are some of the capabilities in which MySQL locking process provides.

No comments:

Post a Comment