PostgreSQL是否针对只读事务运行一些性能优化 [英] Does PostgreSQL run some performance optimizations for read-only transactions

查看:200
本文介绍了PostgreSQL是否针对只读事务运行一些性能优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据参考文档只读

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:


  1. READ_ONLY标志不一定提供任何优化

  2. 设置READ_ONLY标志的主要好处是确保不会出现任何元组修改

这篇关于PostgreSQL是否针对只读事务运行一些性能优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆