{"Entry":{"collection":"guc","key":"client_connection_check_interval","name":"client_connection_check_interval","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Connections and Authentication / TCP Settings","category_zh":"","changed_in":["16","18"],"changes":[{"documentation_changed":false,"fields":{},"from":"13","status":"added","to":"14"},{"documentation_changed":true,"fields":{},"from":"14","status":"changed","to":"15"},{"documentation_changed":false,"fields":{"category":{"from":"Connections and Authentication / Connection Settings","to":"Connections and Authentication / TCP Settings"}},"from":"15","status":"changed","to":"16"},{"documentation_changed":false,"fields":{"extra_desc":{"from":null,"to":"0 disables connection checks."}},"from":"17","status":"changed","to":"18"}],"content_hash":"e6cb807583f447483b5063e7904c8cb4282ae29e5988f96b8f4de330294e8f07","context":"","default_changed_in":[],"default_history":[{"from":"14","to":"19","value":"0 ms"}],"editorial":{"advice":{"olap":"Long analytical queries can benefit from periodic disconnect detection because they may otherwise run after a client disappears; the interval does not cap a healthy query's runtime.","oltp":"Use a nonzero client_connection_check_interval only when abandoning work after client loss materially saves capacity and the platform supports the check. Measure the polling overhead at the chosen interval.","small":"Leave zero unless orphaned long queries are observed. If enabled, choose an interval that detects waste without adding excessive checks to active queries."},"mechanism":["client_connection_check_interval sets the time interval between checks for disconnection while running queries. 0 disables connection checks. A nonzero interval lets long-running queries notice a dead client before their next socket write; operating-system support determines whether checks are effective.","client_connection_check_interval 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 client_connection_check_interval 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 client_connection_check_interval globally without a rollback plan and a client or operational compatibility test."],"references":[{"title":"PostgreSQL 19 Beta 4: client_connection_check_interval","url":"https://www.postgresql.org/docs/19/runtime-config-connection.html#GUC-CLIENT-CONNECTION-CHECK-INTERVAL"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["tcp_keepalives_idle","tcp_keepalives_interval","tcp_keepalives_count","tcp_user_timeout","authentication_timeout"],"summary":"client_connection_check_interval is the PostgreSQL setting that defines the time interval between checks for disconnection while running queries."},"enumvals":[],"first_version":"14","group":"Connections and Authentication","group_slug":"connection","imported_at":"2026-09-27T17:57:30.941845+08:00","intro_commit":{"authored_at":"2021-04-03T08:52:30+13:00","discussion":["https://postgr.es/m/77def86b27e41f0efcba411460e929ae%40postgrespro.ru"],"hash":"c30f54ad732ca5c8762bb68bbe0f51de9137dd72","subject":"Detect POLLHUP/POLLRDHUP while running queries.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=c30f54ad732ca5c8762bb68bbe0f51de9137dd72"},"key":"client_connection_check_interval","last_version":"20","max_val":"","min_val":"","name":"client_connection_check_interval","position":60,"present_in":["14","15","16","17","18","19","20"],"short_desc":"Sets the time interval between optional checks that the client is still connected, while running queries.","short_desc_zh":"","source_rev":"english-manuals:129a593317661b2c76bf55571207ab4cc8c4bdb24130dc75dc051f381a1d47c1","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"client_connection_check_interval","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"client_connection_check_interval","SourceRevision":"english-manuals:129a593317661b2c76bf55571207ab4cc8c4bdb24130dc75dc051f381a1d47c1","Facts":{"boot_val":"0","category":"Connections and Authentication / TCP Settings","context":"user","description":"Sets the time interval between optional checks that the client is still connected, while running queries. The check is performed by polling the socket, and allows long running queries to be aborted sooner if the kernel reports that the connection is closed. This option relies on kernel events exposed by Linux, macOS, illumos and the BSD family of operating systems, and is not currently available on other systems. If the value is specified without units, it is taken as milliseconds. The default value is 0, which disables connection checks. Without connection checks, the server will detect the loss of the connection only at the next interaction with the socket, when it waits for, receives or sends data. For the kernel itself to detect lost TCP connections reliably and within a known timeframe in all scenarios including network failure, it may also be necessary to adjust the TCP keepalive settings of the operating system, or the tcp_keepalives_idle, tcp_keepalives_interval and tcp_keepalives_count settings of PostgreSQL.","doc":{"anchor":"GUC-CLIENT-CONNECTION-CHECK-INTERVAL","file":"runtime-config-connection.html","lang":"en","sha256":"567ba928f3e4c4783f548dc8a54f1e748f02bbe163924605f2132eb5b0da440d","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"0 disables connection checks.","lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"0","name":"client_connection_check_interval","short_desc":"Sets the time interval between checks for disconnection while running queries.","source":"pg-settings-source-snapshot","unit":"ms","vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-CLIENT-CONNECTION-CHECK-INTERVAL","file":"runtime-config-connection.html","lang":"en","sha256":"567ba928f3e4c4783f548dc8a54f1e748f02bbe163924605f2132eb5b0da440d","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"client_connection_check_interval","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"client_connection_check_interval","Summary":"","BodyHTML":"\u003cp\u003e设置查询执行期间可选的客户端连接检查的时间间隔，用于检查客户端是否仍然连接。检查通过轮询套接字执行；如果内核报告连接已经关闭，就可以更早中止长时间运行的查询。\u003c/p\u003e\u003cp\u003e此选项依赖 Linux、macOS、illumos 和 BSD 系列操作系统提供的内核事件，目前在其他系统上不可用。\u003c/p\u003e\u003cp\u003e如果指定值时没有单位，则以毫秒计。默认值为 \u003ccode\u003e0\u003c/code\u003e，表示禁用连接检查。如果不进行连接检查，服务器只有在下一次与套接字交互（等待、接收或发送数据）时，才会检测到连接丢失。\u003c/p\u003e\u003cp\u003e要让内核本身在包括网络故障在内的所有场景中，能够在确定的时间范围内可靠地检测到 TCP 连接丢失，可能还需要调整操作系统的 TCP keepalive 设置，或 \u003cspan\u003ePostgreSQL\u003c/span\u003e 的\u003ca href=\"/docs/18/runtime-config-connection.html#GUC-TCP-KEEPALIVES-IDLE\" rel=\"nofollow\"\u003etcp_keepalives_idle\u003c/a\u003e、\u003ca href=\"/docs/18/runtime-config-connection.html#GUC-TCP-KEEPALIVES-INTERVAL\" rel=\"nofollow\"\u003etcp_keepalives_interval\u003c/a\u003e和\u003ca href=\"/docs/18/runtime-config-connection.html#GUC-TCP-KEEPALIVES-COUNT\" rel=\"nofollow\"\u003etcp_keepalives_count\u003c/a\u003e设置。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"f794b03aeebb88a529c070f837a9e3d89275283875915da749d8a3bc1d8602ad","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e设置查询执行期间可选的客户端连接检查的时间间隔，用于检查客户端是否仍然连接。检查通过轮询套接字执行；如果内核报告连接已经关闭，就可以更早中止长时间运行的查询。\u003c/p\u003e\u003cp\u003e此选项依赖 Linux、macOS、illumos 和 BSD 系列操作系统提供的内核事件，目前在其他系统上不可用。\u003c/p\u003e\u003cp\u003e如果指定值时没有单位，则以毫秒计。默认值为 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e，表示禁用连接检查。如果不进行连接检查，服务器只有在下一次与套接字交互（等待、接收或发送数据）时，才会检测到连接丢失。\u003c/p\u003e\u003cp\u003e要让内核本身在包括网络故障在内的所有场景中，能够在确定的时间范围内可靠地检测到 TCP 连接丢失，可能还需要调整操作系统的 TCP keepalive 设置，或 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 的\u003ca href=\"/docs/18/runtime-config-connection.html#GUC-TCP-KEEPALIVES-IDLE\"\u003etcp_keepalives_idle\u003c/a\u003e、\u003ca href=\"/docs/18/runtime-config-connection.html#GUC-TCP-KEEPALIVES-INTERVAL\"\u003etcp_keepalives_interval\u003c/a\u003e和\u003ca href=\"/docs/18/runtime-config-connection.html#GUC-TCP-KEEPALIVES-COUNT\"\u003etcp_keepalives_count\u003c/a\u003e设置。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
