Skip to content

docs(pgxpool): correct the documented pool_max_conns default - #2638

Merged
jackc merged 1 commit into
jackc:masterfrom
shaikn6:docs/pgxpool-max-conns-default
Sep 7, 2026
Merged

jackc merged 1 commit into
jackc:masterfrom
shaikn6:docs/pgxpool-max-conns-default

Conversation

@shaikn6

@shaikn6 shaikn6 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

ParseConfig's doc comment lists:

//   - pool_max_conns: integer greater than 0 (default 4)

But when pool_max_conns is not supplied, the code sets it to the greater of 4 and runtime.NumCPU():

} else {
    config.MaxConns = defaultMaxConns            // 4
    if numCPU := int32(runtime.NumCPU()); numCPU > config.MaxConns {
        config.MaxConns = numCPU
    }
}

So on any host with more than 4 CPUs the effective default is NumCPU, not 4 — which matters for capacity planning against max_connections. The Config.MaxConns field doc already states this correctly ("The default is the greater of 4 or runtime.NumCPU()"); this just brings the ParseConfig parameter list in line with it.

One-line comment change. No code, no behavior change.

ParseConfig's doc lists 'pool_max_conns: ... (default 4)', but when the
parameter is unset the code sets MaxConns to the greater of 4 and
runtime.NumCPU() (pool.go, the else branch a few lines below). On any host
with more than 4 CPUs the effective default is NumCPU, not 4. The Config.MaxConns
field doc already states it correctly; this aligns the ParseConfig list with it.
@jackc
jackc merged commit 31e57c2 into jackc:master Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants