innodb中,普通读不加读锁

http://dev.mysql.com/doc/refman/5.5/en/innodb-consistent-read.html

"Consistent read(即普通select) is the default mode in which InnoDB processes SELECT statements in READ COMMITTED and REPEATABLE READ isolation levels. "

"
A consistent read does not set any locks on the tables it accesses"

因此另一个事务可以随便改:

" and therefore other sessions are free to modify those tables at the same time a consistent read is being performed on the table."

不用读锁了,那怎么保证repeatable read?  这就要归功于mysql的MVCC机制了。在MVCC机制中,我们可以理解每个事务对同一份数据有自己的数据空间,你的改动跟我无关(类似于java中的threadlocal)

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.