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

引自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.

转载注明原文:postgresql事务级别可重复读取和序列化是否相同? - 代码日志