You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sql-pg: PgClient.make keeps its session pool private, so apps can't export pool occupancy metrics #9086
Could the native PostgreSQL client expose a supported snapshot of connection-pool occupancy: idle sessions, used sessions, callers waiting for a session, and the configured maximum?
This is an API/observability request, not a driver correctness bug.
PgClient.make constructs a PgPool and returns the client without exposing that pool or a statistics snapshot (PgClient.ts L177-L185).
PgPool exposes acquisition operations but no occupancy API (PgPool.ts L75-L107). Its underlying effect/Pool is local to the implementation (L145-L172).
Older fromPool accepted a caller-provided pg.Pool, whose counters were publicly observable. #7426 replaced that adapter with the native driver. This request is not to restore the old adapter.
Related: #8676 adds statement wait/connect tracing. An occupancy snapshot or gauges would complement that, rather than duplicate it.
Possible API
For example, a proposed client-level API (not one that exists today):
Built-in gauges would also cover the capability. Raw access to the underlying pool is not necessary and could bypass the driver's TTL/dead-session handling.
With multiplexing, used sessions and in-flight statements are different counts. A statistics snapshot should define which it reports and should not imply a synchronization guarantee.
Environment
Effect 4.0.3 and @effect/sql-pg 4.0.3.
Public API checked at 1bfd8fddebc978643b7a2077a837b82dc8998177.
Activity
test: specify pool occupancy stats for Pool, PgPool, and PgClient
test: specify pool occupancy stats for Pool, PgPool, and PgClient