A simple normal (no lock) SQL, regardless of the transaction situation
1: If a query operation and a write operation are performed at the same time, will MySQL automatically lock?
2: What if the operation of two or more queries is performed concurrently?
3: What if two write operations are performed simultaneously?
3: What if one reads and one writes at the same time?
does not consider the case of a transaction.
Reply content:
A simple normal (no lock) SQL, regardless of the transaction situation
1: If a query operation and a write operation are performed at the same time, will MySQL automatically lock?
2: What if the operation of two or more queries is performed concurrently?
3: What if two write operations are performed simultaneously?
3: What if one reads and one writes at the same time?
does not consider the case of a transaction.
Give yourself a supplementary answer:
1:innodb the different select does not have any lock, MyISAM will automatically add the table to share the read lock;
2:innodb There is no lock, so there is no problem, MyISAM is a table shared read lock, shared read locks are not conflicting with each other, is parallel;
3:myisam is the table exclusive write lock, table-level lock, is serial, write lock will block each other, must write the SQL is a piece of execution. InnoDB the situation is a bit more complicated, InnoDB uses the row lock, of course, with respect to the index (impact plus lock), will automatically add row lock:
Exclusive Lock (X): A transaction that allows an exclusive lock to update data, preventing other transactions from acquiring shared read and exclusive write locks of the same data set.
Therefore, if there is no row lock conflict, there is no effect on each other, or there will be lock blocking.
, lock granularity may also appear deadlock, that is: waiting for the lock will be a deadlock, when a thing found it to wait for the release of the lock transaction while also waiting for it to release the lock, it will occur deadlock exit, release the lock, let the former get lock;
4: For the ordinary SELECT statement, InnoDB will not add any locks, so read and write at the same time no problem, read as snapshot read, write as the current read, for MyISAM to see which process first to obtain a table lock, read and write is serial.
Reference: http://blog.csdn.net/xifeijian/article/details/20313977
Reference: http://blog.csdn.net/xifeijian/article/details/20312557
Auto Lock, Update is atomic operation