PostgreSQL是否针对只读事务运行一些性能优化 [英] Does PostgreSQL run some performance optimizations for read-only transactions
问题描述
根据参考文档只读
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
除非
交易,否则DEFERRABLE交易属性无效。也可SERIALIZERZED和只读。当为交易选择所有三个
属性时,该交易在首次获取其快照时可能会阻塞
,此后它可以运行
而没有SERIALIZABLE事务的正常开销,并且没有
会导致序列化
失败或被其取消的任何风险。此模式非常适合长时间运行的报告或备份。
The DEFERRABLE transaction property has no effect unless the transaction is also SERIALIZABLE and READ ONLY. When all three of these properties are selected for a transaction, the transaction may block when first acquiring its snapshot, after which it is able to run without the normal overhead of a SERIALIZABLE transaction and without any risk of contributing to or being canceled by a serialization failure. This mode is well suited for long-running reports or backups.
数据库引擎是否对只读事务运行其他优化? / p>
Does the database engine runs other optimizations for read-only transactions?
推荐答案
总结尼克·巴恩斯(Nick Barnes)和克雷格·林格(Craig Ringer)在问题评论中的评论:
To sum up the comments from Nick Barnes and Craig Ringer in the question comments:
- READ_ONLY标志不一定提供任何优化
- 设置READ_ONLY标志的主要好处是确保不会出现任何元组修改
这篇关于PostgreSQL是否针对只读事务运行一些性能优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!