加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 16:19:10 所属栏目:百科 来源:网络整理
导读:考虑在PostgreSQL 9.1(或9.2)中执行的以下查询: SELECT * FROM foo WHERE bar = true 假设这是一个相当长时间运行的查询(例如花一分钟). 如果在查询开始时有500万条记录,其中bar = true,则在另一个事务中的查询期间,在foo表中添加和删除行,对于某些现有行,
考虑在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.

强调我的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读