Skip to content

client_connection_check_interval

client_connection_check_interval is the PostgreSQL setting that defines the time interval between checks for disconnection while running queries.
Note

Fact — official short description: “Sets the time interval between checks for disconnection while running queries.”

Identity

Type , Valueinteger
Upstream pg_settings type
Context , Valueuser
Settable by an ordinary user
Unit , Valuems
Raw unit
Range , Value02147483647
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueConnections and Authentication / TCP Settings
Upstream classification
Latest boot value , Value0
0 ms

Lifecycle

Fact Value
First observed PG14
Present in PG14–19 Beta 3
Removed in No
Introduction commit c30f54ad732c — Detect POLLHUP/POLLRDHUP while running queries.
Commit date 2021-04-03
Discussion thread 1

Default history

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG14–19 Beta 3 0 ms 0 ms

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.

Tuning advice

Tip

Advice. These are workload-specific starting points and must be validated with measurements.

Workload Guidance
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.
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.
Small nodes Leave zero unless orphaned long queries are observed. If enabled, choose an interval that detects waste without adding excessive checks to active queries.

Pigsty

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

Template Effective value Versus upstream boot Source expression
OLTP Unmodified
OLAP Unmodified
CRIT Unmodified
TINY Unmodified
Caution

Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG14–19 Beta 3 unmodified; OLAP: PG14–19 Beta 3 unmodified; CRIT: PG14–19 Beta 3 unmodified; TINY: PG14–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

Common 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.

tcp_keepalives_idle · tcp_keepalives_interval · tcp_keepalives_count · tcp_user_timeout · authentication_timeout

References