并发值修改会影响PostgreSQL 9.1中的单选吗?

前端之家收集整理的这篇文章主要介绍了并发值修改会影响PostgreSQL 9.1中的单选吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
考虑在Postgresql 9.1(或9.2)中执行的以下查询
SELECT * FROM foo WHERE bar = true

假设这是一个相当长时间运行的查询(例如花一分钟).

如果在查询开始时有500万条记录,其中bar = true,则在另一个事务中的查询期间,在foo表中添加删除行,对于某些现有行,对条形字段进行更新.

这会影响上面显示的选择查询的结果吗?

我知道单个事务中单独语句之间的事务隔离和可见性,但是正在运行的单个语句呢?

没有.
由于MVCC模型,只有在查询开始时可见的元组才会在单个SELECT中使用.手册 here中的详细信息:

Read Committed is the default isolation level in Postgresql. When a
transaction uses this isolation level,a SELECT query (without a FOR
UPDATE/SHARE clause) sees only data committed before the query began;
it never sees either uncommitted data or changes committed during
query execution by concurrent transactions
. In effect,a SELECT query
sees a snapshot of the database as of the instant the query begins to
run. However,SELECT does see the effects of prevIoUs updates executed
within its own transaction,even though they are not yet committed.
Also note that two successive SELECT commands can see different data,
even though they are within a single transaction,if other
transactions commit changes during execution of the first SELECT.

强调我的.

猜你在找的Postgre SQL相关文章