For the “slow database or empty pool?” case, time three things separately on the app side: checkout wait, query execution, and how long the connection stays checked out. During a spike, use a separate diagnostic connection and inspect pg_stat_activity for the app’s application_name. Look at state, wait_event_type, and xact_start. A long “idle in transaction” session points to an open transaction between statements. It doesn’t prove a leak by itself, so correlate it with checkout duration and the code path that owns that connection.
SqlOtter
For the “slow database or empty pool?” case, time three things separately on the app side: checkout wait, query execution, and how long the connection stays checked out. During a spike, use a separate diagnostic connection and inspect pg_stat_activity for the app’s application_name. Look at state, wait_event_type, and xact_start. A long “idle in transaction” session points to an open transaction between statements. It doesn’t prove a leak by itself, so correlate it with checkout duration and the code path that owns that connection.