## TL;DR

Set persistence.datastores.*.sql.maxConns and maxIdleConns explicitly. 1. cluster with 2k shards (I assume that's the culprit) 1. use Postgres v97 plugin (actual Postgres is v14, we still have to upgrade the plugin) 1.

## Steps

1. cluster with 2k shards (I assume that's the culprit)
 1. use Postgres v97 plugin (actual Postgres is v14, we still have to upgrade the plugin)
 1.

2. [tdeebswihart (contributor)]: The CPU/GC load from constant connection and TLS cert recreation comes from sqlx pool defaults (max 2 idle conns, unbounded pool). Set persistence.datastores.*.sql.maxConns and maxIdleConns explicitly. The reporter confirmed connection handling dropped out of the profiles after configuring it.

## When to use

You are seeing this: Issue temporalio/temporal#4975 (closed, 13 comments): ## Expected Behavior Connections rarely getting opened Use this skill when you run into "Postgres connection pooling not working".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: v1.20. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
