perf(db): bump postgres pool to 60 in development to prevent hub-hang under fanout load
Default max=20 was saturating during normal admin clickthrough — the clients list page does aggregate-per-client queries (yachts, memberships, interests, contacts) that fan out 5-6 connections per row, plus dashboard analytics, plus React Query refetch-on-focus. With 20 slots, the server appeared to hang for 30s (statement_timeout) until queries released their slots. Production keeps the conservative max=20 since multi-replica deployments share the postgres max_connections budget. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,14 @@ const connectionString = process.env.DATABASE_URL!;
|
||||
// `max_lifetime` recycles connections every 30 minutes so any
|
||||
// per-connection state drift (prepared statements, GUCs) doesn't
|
||||
// accumulate forever.
|
||||
// Larger pool in development because Next dev fans out (HMR refetches,
|
||||
// multi-widget dashboards, React Query refetch-on-focus) and a single
|
||||
// admin clicking around can saturate 20 slots. Production stays at the
|
||||
// conservative 20 so we don't hammer postgres in a multi-replica deploy.
|
||||
const POOL_MAX = process.env.NODE_ENV === 'development' ? 60 : 20;
|
||||
|
||||
const queryClient = postgres(connectionString, {
|
||||
max: 20,
|
||||
max: POOL_MAX,
|
||||
idle_timeout: 20,
|
||||
connect_timeout: 10,
|
||||
max_lifetime: 60 * 30,
|
||||
|
||||
Reference in New Issue
Block a user