{"Entry":{"collection":"guc","key":"idle_in_transaction_session_timeout","name":"idle_in_transaction_session_timeout","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Client Connection Defaults / Statement Behavior","category_zh":"","changed_in":["14","18"],"changes":[{"documentation_changed":false,"fields":{},"from":"9.5","status":"added","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"},{"documentation_changed":true,"fields":{"short_desc":{"from":"Sets the maximum allowed duration of any idling transaction.","to":"Sets the maximum allowed idle time between queries, when in a transaction."}},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"A value of 0 turns off the timeout.","to":"0 disables the timeout."}},"from":"17","status":"changed","to":"18"}],"content_hash":"12495eae4a774e940ef18eedadfdf1718bd08a5bd3e16fb6e3074e54b107c236","context":"","default_changed_in":[],"default_history":[{"from":"9.6","to":"19","value":"0 ms"}],"editorial":{"advice":{"olap":"Analytical work usually needs a larger or job-specific idle_in_transaction_session_timeout; preserve a finite guardrail for abandoned work without killing legitimate long scans.","oltp":"Set idle_in_transaction_session_timeout from the service latency and failure budget, preferably per role or application. Test retries and cancellation paths before enforcing a cluster-wide value.","small":"Use a conservative finite idle_in_transaction_session_timeout only when the client or operating system handles termination correctly; verify that maintenance still has a dedicated exception."},"mechanism":["idle_in_transaction_session_timeout sets the maximum allowed idle time between queries, when in a transaction. 0 disables the timeout. It terminates sessions idle inside an open transaction, releasing locks and old snapshots that can block vacuum cleanup and cause bloat.","idle_in_transaction_session_timeout is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.","Timeouts overlap: the first applicable deadline wins, while client, pooler, TCP, and server cancellation behavior determines whether work is retried, canceled, or the session is closed."],"pitfalls":["Changing idle_in_transaction_session_timeout in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Forgetting that zero usually disables the timeout or delegates behavior to the operating system.","Setting overlapping deadlines without deciding which layer owns retries, cancellation, and connection disposal.","Changing idle_in_transaction_session_timeout globally without a rollback plan and a client or operational compatibility test."],"references":[{"title":"PostgreSQL 19 Beta 4: idle_in_transaction_session_timeout","url":"https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["statement_timeout","lock_timeout","transaction_timeout","idle_session_timeout","deadlock_timeout"],"summary":"idle_in_transaction_session_timeout is the PostgreSQL setting that defines the maximum allowed idle time between queries, when in a transaction."},"enumvals":[],"first_version":"9.6","group":"Client Connection Defaults","group_slug":"client","imported_at":"2026-09-27T17:57:31.375675+08:00","intro_commit":{"authored_at":"2016-03-16T11:30:45-04:00","discussion":[],"hash":"c6dda1f48e573cc60fe25d8d470a05bfabed0252","subject":"Add idle_in_transaction_session_timeout.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=c6dda1f48e573cc60fe25d8d470a05bfabed0252"},"key":"idle_in_transaction_session_timeout","last_version":"20","max_val":"","min_val":"","name":"idle_in_transaction_session_timeout","position":173,"present_in":["9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"Terminate any session that has been idle (that is, waiting for a client query) within an open transaction for longer than the specified amount of time.","short_desc_zh":"","source_rev":"english-manuals:ef09b7be61a077b9dbe841d7eda4f8386d0873566381ca73d580fcc540ddec20","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"idle_in_transaction_session_timeout","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"idle_in_transaction_session_timeout","SourceRevision":"english-manuals:ef09b7be61a077b9dbe841d7eda4f8386d0873566381ca73d580fcc540ddec20","Facts":{"boot_val":"0","category":"Client Connection Defaults / Statement Behavior","context":"user","description":"Terminate any session that has been idle (that is, waiting for a client query) within an open transaction for longer than the specified amount of time. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout. This option can be used to ensure that idle sessions do not hold locks for an unreasonable amount of time. Even when no significant locks are held, an open transaction prevents vacuuming away recently-dead tuples that may be visible only to this transaction; so remaining idle for a long time can contribute to table bloat. See Section 24.1 for more details.","doc":{"anchor":"GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"0 disables the timeout.","lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"0","name":"idle_in_transaction_session_timeout","short_desc":"Sets the maximum allowed idle time between queries, when in a transaction.","source":"pg-settings-source-snapshot","unit":"ms","vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"idle_in_transaction_session_timeout","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"idle_in_transaction_session_timeout","Summary":"","BodyHTML":"\u003cp\u003e终止在打开的事务中空闲（即等待客户端查询）超过指定时长的任何会话。如果指定值时不带单位，则以毫秒为单位。零值（默认值）禁用此超时。\u003c/p\u003e\u003cp\u003e此选项可确保空闲会话不会持有锁过长时间。即使没有持有重要的锁，打开的事务也会阻止清理最近死亡、且可能只对该事务可见的元组；因此长时间空闲可能造成表膨胀。更多详情参见\u003ca href=\"/docs/18/routine-vacuuming.html\" rel=\"nofollow\"\u003e第 24.1 节\u003c/a\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"f60ac633fc7ae87fabd2f391836e3cddaf8090d1dc31877903e5e00d20a26395","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e终止在打开的事务中空闲（即等待客户端查询）超过指定时长的任何会话。如果指定值时不带单位，则以毫秒为单位。零值（默认值）禁用此超时。\u003c/p\u003e\u003cp\u003e此选项可确保空闲会话不会持有锁过长时间。即使没有持有重要的锁，打开的事务也会阻止清理最近死亡、且可能只对该事务可见的元组；因此长时间空闲可能造成表膨胀。更多详情参见\u003ca href=\"/docs/18/routine-vacuuming.html\" title=\"24.1. 日常清理\"\u003e第 24.1 节\u003c/a\u003e。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
