今天小伙伴问了一个sql的问题: update t set status=2 where id in(select id from t where status=1) 这个sql,在并发的情况下,会不会有问题? 假设:下面的讨论,数据库的事务隔离级别是read_committed 其实这个可以很容易测试一下,得出结论:存在丢失更新的问题. 先来理解两个概念: 1. 一致性读 当前的数据库产品级别都实现了多版本一致性,即MVCC,那么有了MVCC,数据库实现了读写互不阻塞的效果. 但为了达到rea
一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文档:http://dev.mysql.com/doc/refman/5.6/en/innodb-consistent-read.html A consistent read means that InnoDB uses multi-versioning to present to a query a snapshot of the database at a point in time.
http://www.cnblogs.com/digdeep/p/4947694.html 一致性读,又称为快照读.使用的是MVCC机制读取undo中的已经提交的数据.所以它的读取是非阻塞的. 相关文档:http://dev.mysql.com/doc/refman/5.6/en/innodb-consistent-read.html A consistent read means that InnoDB uses multi-versioning to present to a query a
MySQL MVCC MySQL InnoDB存储引起实现的是基于多版本的并发控制协议---MVCC(Multi-Version Concurrency Control),基于锁的并发控制,Lock-Based Concurrency Control. 一致性读,又称快照读,读取的是undo中已提交的数据,可能是数据的历史版本,no-locking,所以是非阻塞的读取操作. A consistent read means that InnoDB uses multi-versioning to
MySQL--一致性非锁定读(快照读) MySQL数据库中读分为一致性非锁定读.一致性锁定读 一致性非锁定读(快照读),普通的SELECT,通过多版本并发控制(MVCC)实现. 一致性锁定读(当前读),SELECT ... FOR UPDATE/SELECT ... LOCK IN SHARE MODE/INSERT/UPDATE/DELETE,通过锁实现. 本文主要介绍一下一致性非锁定读,简单看一下2个场景: -- 创建表tx create table t (id int auto_incre
The so-called phantom problem occurs within a transaction when the same query produces different sets of rows at different times. For example, if a SELECT is executed twice, but returns a row the second time that was not returned the first time, the
mysql数据库预读与不预读数据库信息(use dbname)—Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A mysql> use dbname Reading table information for completion of table and column names