{"Entry":{"collection":"guc","key":"idle_session_timeout","name":"idle_session_timeout","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Client Connection Defaults / Statement Behavior","category_zh":"","changed_in":["18"],"changes":[{"documentation_changed":false,"fields":{},"from":"13","status":"added","to":"14"},{"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":"42644475eb551920d065f162f86709bdc6960745edd82f00e4c86f4422802798","context":"","default_changed_in":[],"default_history":[{"from":"14","to":"19","value":"0 ms"}],"editorial":{"advice":{"olap":"Analytical work usually needs a larger or job-specific idle_session_timeout; preserve a finite guardrail for abandoned work without killing legitimate long scans.","oltp":"Set idle_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_session_timeout only when the client or operating system handles termination correctly; verify that maintenance still has a dedicated exception."},"mechanism":["idle_session_timeout sets the maximum allowed idle time between queries, when not in a transaction. 0 disables the timeout. It closes sessions idle outside a transaction; such sessions are usually cheap, and poolers may react badly to unexpected server-side closure.","idle_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_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_session_timeout globally without a rollback plan and a client or operational compatibility test."],"references":[{"title":"PostgreSQL 19 Beta 4: idle_session_timeout","url":"https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-IDLE-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_in_transaction_session_timeout","deadlock_timeout"],"summary":"idle_session_timeout is the PostgreSQL setting that defines the maximum allowed idle time between queries, when not in a transaction."},"enumvals":[],"first_version":"14","group":"Client Connection Defaults","group_slug":"client","imported_at":"2026-09-27T17:57:31.383209+08:00","intro_commit":{"authored_at":"2021-01-06T18:28:42-05:00","discussion":["https://postgr.es/m/763A0689-F189-459E-946F-F0EC4458980B@hotmail.com"],"hash":"9877374bef76ef03923f6aa8b955f2dbcbe6c2c7","subject":"Add idle_session_timeout.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=9877374bef76ef03923f6aa8b955f2dbcbe6c2c7"},"key":"idle_session_timeout","last_version":"20","max_val":"","min_val":"","name":"idle_session_timeout","position":175,"present_in":["14","15","16","17","18","19","20"],"short_desc":"Terminate any session that has been idle (that is, waiting for a client query), but not within an open transaction, for longer than the specified amount of time.","short_desc_zh":"","source_rev":"english-manuals:0e75ad2eb947e27c01822d6241ac5e860a3638d57b14b9ec974a22f372be9a20","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"idle_session_timeout","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"idle_session_timeout","SourceRevision":"english-manuals:0e75ad2eb947e27c01822d6241ac5e860a3638d57b14b9ec974a22f372be9a20","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), but not 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. Unlike the case with an open transaction, an idle session without a transaction imposes no large costs on the server, so there is less need to enable this timeout than idle_in_transaction_session_timeout. Be wary of enforcing this timeout on connections made through connection-pooling software or other middleware, as such a layer may not react well to unexpected connection closure. It may be helpful to enable this timeout only for interactive sessions, perhaps by applying it only to particular users.","doc":{"anchor":"GUC-IDLE-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_session_timeout","short_desc":"Sets the maximum allowed idle time between queries, when not in a transaction.","source":"pg-settings-source-snapshot","unit":"ms","vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-IDLE-SESSION-TIMEOUT","file":"runtime-config-client.html","lang":"en","sha256":"6be6cc70f29eca4695dc43b2b2b94c75b7e0eaaa2c00273d7a98488917a7edb7","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"idle_session_timeout","SourceDatabase":"center","Version":"18","Locale":"en","Title":"idle_session_timeout","Summary":"Terminate any session that has been idle (that is, waiting for a client query), but not 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. Unlike the case with an open transaction, an idle session without a transaction imposes no large costs on the server, so there is less need to enable this timeout than idle_in_transaction_session_timeout. Be wary of enforcing this timeout on connections made through connection-pooling software or other middleware, as such a layer may not react well to unexpected connection closure. It may be helpful to enable this timeout only for interactive sessions, perhaps by applying it only to particular users.","BodyHTML":"\u003cp\u003eTerminate any session that has been idle (that is, waiting for a client query), but not 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. Unlike the case with an open transaction, an idle session without a transaction imposes no large costs on the server, so there is less need to enable this timeout than idle_in_transaction_session_timeout. Be wary of enforcing this timeout on connections made through connection-pooling software or other middleware, as such a layer may not react well to unexpected connection closure. It may be helpful to enable this timeout only for interactive sessions, perhaps by applying it only to particular users.\u003c/p\u003e","SourceRevision":"english-manuals:0e75ad2eb947e27c01822d6241ac5e860a3638d57b14b9ec974a22f372be9a20","ContentHash":"b895576872b94acdc7ec468fa3417c6b3ffd9b808b1628dab4f96aa520acfaf8","Payload":{"description":"Terminate any session that has been idle (that is, waiting for a client query), but not 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. Unlike the case with an open transaction, an idle session without a transaction imposes no large costs on the server, so there is less need to enable this timeout than idle_in_transaction_session_timeout. Be wary of enforcing this timeout on connections made through connection-pooling software or other middleware, as such a layer may not react well to unexpected connection closure. It may be helpful to enable this timeout only for interactive sessions, perhaps by applying it only to particular users."}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
