Skip to content

NIP: Postgres slow queries

Alert: NipPostgresSlowQueries · Severity: Warning

What this means

An active query has run >30 seconds.

Fix

docker exec inward_dev-db-1 psql -U $USER -d $DB -c \
  "SELECT pid, now()-query_start AS dur, state, left(query,120) FROM pg_stat_activity WHERE state='active' ORDER BY dur DESC LIMIT 10;"
  1. Identify blocking query — app migration, missing index, lock.
  2. Do not pg_terminate_backend without app team unless emergency.
  3. Correlate timestamp with transfer slowness.

Escalate if

Multiple slow queries or CBS_SENT stuck rows increasing.