{"Entry":{"collection":"guc","key":"default_transaction_read_only","name":"default_transaction_read_only","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Client Connection Defaults / Statement Behavior","category_zh":"","changed_in":[],"changes":[{"documentation_changed":true,"fields":{},"from":"8.0","status":"changed","to":"8.1"}],"content_hash":"e8e854295926ba5fb8c31b17f9d07f6232fd6fde2731507b465c4eb2cc0e1614","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"off"}],"derived_content_hash":"82256d622a1cc27477a1d87a2d8eb1bf8fc686e74290fa6d9f6db404bfb2f66c","editorial":{"advice":{"olap":"For reporting, consider a read-only transaction and an isolation choice that matches snapshot requirements; use deferrability only with read-only serializable work.","oltp":"Choose default_transaction_read_only for correctness semantics first. Keep the common OLTP path explicit, then override only transactions whose consistency contract justifies different blocking or retry behavior.","small":"Do not change default_transaction_read_only as a generic speed tweak. Higher isolation or long snapshots can amplify contention and vacuum pressure on a small node."},"mechanism":["default_transaction_read_only sets the default read-only status of new transactions. Each transaction inherits this default, but read-only mode still permits temporary-table changes and does not substitute for standby or privilege enforcement.","default_transaction_read_only is a USER-context setting and can be assigned per role, database, or session; its value is copied when a new transaction starts, so it does not rewrite a transaction already in progress.","The default_* variables seed the corresponding transaction_* state. Isolation, read-only status, deferrability, retries, and snapshot lifetime must be designed together."],"pitfalls":["Changing default_transaction_read_only in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Changing transaction semantics as a performance experiment and silently weakening an application's consistency contract.","Letting a pooled session retain transaction-related state because checkout or rollback/reset handling is incomplete.","Changing default_transaction_read_only globally without a rollback plan and a client or operational compatibility test."],"references":[{"title":"PostgreSQL 19 Beta 4: default_transaction_read_only","url":"https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["default_transaction_isolation","transaction_isolation","transaction_read_only","default_transaction_deferrable","transaction_deferrable"],"summary":"default_transaction_read_only is the PostgreSQL setting that defines the default read-only status of new transactions."},"enumvals":[],"first_version":"7.4","group":"Client Connection Defaults","group_slug":"client","imported_at":"2026-09-27T17:57:31.12969+08:00","intro_commit":{},"key":"default_transaction_read_only","last_version":"20","max_val":"","min_val":"","name":"default_transaction_read_only","position":105,"present_in":["7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:f0589d4d182917fa5aa886491bf4991b0c09af141e6691a0742ac94b1420d5c9","receipt_sha256":"d42031efbfaae04a90d108502798ab050a507e4e417affc0dfe68151bb90ab3f","repair":"wiki-repair-20261023"},"short_desc":"A read-only SQL transaction cannot alter non-temporary tables.","short_desc_zh":"","source_rev":"wiki-repair-20261023:49ebe989fcaf6d43d347ec0fb693dc2d3ff5bc810ebb644f242444aa6e04666e","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"default_transaction_read_only","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"default_transaction_read_only","SourceRevision":"wiki-repair-20261023:49ebe989fcaf6d43d347ec0fb693dc2d3ff5bc810ebb644f242444aa6e04666e","Facts":{"boot_val":"off","category":"Client Connection Defaults / Statement Behavior","context":"user","description":"A read-only SQL transaction cannot alter non-temporary tables. This parameter controls the default read-only status of each new transaction. The default is off (read/write). Consult SET TRANSACTION for more information.","description_zh":"一个只读的 SQL 事务不能修改非临时表。这个参数控制每个新事务的默认只读状态。默认是 off（读/写）。 更多信息请参考 SET TRANSACTION。","description_zh_html":"\u003cp\u003e\n        一个只读的 SQL 事务不能修改非临时表。这个参数控制每个新事务的默认只读状态。默认是 \u003ccode class=\"literal\"\u003eoff\u003c/code\u003e（读/写）。\n       \u003c/p\u003e\u003cp\u003e\n        更多信息请参考 \u003ca class=\"xref\" href=\"/zh/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e。\n       \u003c/p\u003e","doc":{"anchor":"GUC-DEFAULT-TRANSACTION-READ-ONLY","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"default_transaction_read_only","short_desc":"Sets the default read-only status of new transactions.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-client.html","sha256":"1882f8fd5576909c4fcc44af53077378871e05f5be67723f20fe300273024767"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"bool","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-DEFAULT-TRANSACTION-READ-ONLY","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"default_transaction_read_only","SourceDatabase":"center","Version":"18","Locale":"en","Title":"default_transaction_read_only","Summary":"A read-only SQL transaction cannot alter non-temporary tables. This parameter controls the default read-only status of each new transaction. The default is off (read/write). Consult SET TRANSACTION for more information.","BodyHTML":"\u003cp\u003eA read-only SQL transaction cannot alter non-temporary tables. This parameter controls the default read-only status of each new transaction. The default is off (read/write). Consult SET TRANSACTION for more information.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:49ebe989fcaf6d43d347ec0fb693dc2d3ff5bc810ebb644f242444aa6e04666e","ContentHash":"af01030da4513fdddc8cc449407c22f9d186bfee77bfe2465b912282bb7c6978","Payload":{"description":"A read-only SQL transaction cannot alter non-temporary tables. This parameter controls the default read-only status of each new transaction. The default is off (read/write). Consult SET TRANSACTION for more information."}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
