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

postgresql事务级别可重复读取和序列化是否相同?

发布时间:2020-12-13 16:05:07 所属栏目:百科 来源:网络整理
导读:引自 http://www.postgresql.org/docs/9.4/static/transaction-iso.html: When you select the level Read Uncommitted you really get Read Committed,and phantom reads are not possible in the PostgreSQL implementation of Repeatable Read,so the ac
引自 http://www.postgresql.org/docs/9.4/static/transaction-iso.html:

When you select the level Read Uncommitted you really get Read Committed,and phantom reads are not possible in the PostgreSQL implementation of Repeatable Read,so the actual isolation level might be stricter than what you select.

澄清一下:它是否意味着pg的可重复读取=可序列化?

解决方法

没有;差异在 the page you linked to中描述:

In fact,this isolation level works exactly the same as Repeatable Read except that it monitors for conditions which could make execution of a concurrent set of serializable transactions behave in a manner inconsistent with all possible serial (one at a time) executions of those transactions.

文档继续给出一个示例,其中Repeatable Read和Serializable的行为不同. Serializable事务可以通过“序列化失败”中止,但不会阻止任何额外的事务完成.

您引用的部分解释了一些异常,因为标准SQL隔离级别是围绕锁定数据设计的,但PostgreSQL是使用“MVCC”设计实现的,其中并发事务可以为数据提供独立的快照.因此,其他系统中存在的一些区别不适用,Postgres将隔离级别解释为“至少与…一样严格”.

正如Mark Hildreth在评论中指出的那样,这种区别仅在PostgreSQL 9.1之后才有效. documentation for 9.0指出:

But internally,there are only two distinct isolation levels,which correspond to the levels Read Committed and Serializable.

而在较新的版本中,这已被修改为:

But internally,there are only three distinct isolation levels,which correspond to the levels Read Committed,Repeatable Read,and Serializable.

(编辑:李大同)

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

    推荐文章
      热点阅读