select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / CONNECTIONS AND AUTHENTICATION

client_connection_check_interval

Read PG 18 manual ↗

Sets the time interval between optional checks that the client is still connected, while running queries.

Type
integer
Context
user
Measured default
0 ms
Unit
ms
Metadata snapshot
18

Definition PG 18 manual

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.

Measured default history
Version intervalDefault
14 – 190 ms
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

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.

Operational considerations

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.

Workload guidance

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.

Version history 4
  1. PG 17 → 18changed
  2. PG 15 → 16changed
  3. PG 14 → 15changed
  4. PG 13 → 14added

Related entries

Further reading

Definition snapshot: english-manuals:c1abbd3e7e90585933f7699fb87… · English manual source