Parameter · Connections and Authentication / TCP Settings
client_connection_check_interval
Sets the time interval between checks for disconnection while running queries. 0 disables connection checks.
- Default:
0 - Type: integer (ms)
- Range: 0 … max (2147483647)
- Applies: Session (any user)
In plain words
If a client disconnects while its long query is still running, PostgreSQL normally only notices when it tries to send the results, maybe hours later. With this setting, the backend checks every so often whether the client is still there and cancels the query early if not.
For DBAs and operators
Added in PostgreSQL 14. While a query runs, the backend polls the socket every interval (it uses POLLRDHUP-style kernel events; available on Linux, macOS, illumos and the BSDs). If the kernel reports the peer has closed the connection, the query is aborted and the session ends with FATAL: connection to client lost, freeing CPU, I/O, locks and temp space.
It only detects disconnects the kernel knows about: a clean close, or a reset. A client machine that vanished silently is detected only after TCP keepalives (or tcp_user_timeout) have declared the connection dead, so combine it with the tcp_keepalives_* settings. The check is cheap; values of a few seconds (e.g. 5s–10s) are common for workloads where users cancel by closing the application or where load balancers time out long reports. It is a user-context setting, so it can be set per role or database.
How to change it
Any user can change it for their session with SET.