Skip to content

Alerting checklist ​

These PostgreSQL 18 signals are operational starting points, not measured coverage of all incidents. The linked Scenarios demonstrate individual fields and schedules. The aggregations, sampling intervals, and example thresholds below are recommendations, not executed alerting rules or engine guarantees.

#Signal to investigateQuery core or example policyEvidence and limits
1Old open transactionsmax(now() - xact_start) from pg_stat_activity, filtered to relevant sessionsLong & idle transactions demonstrates age over one second, not a universal maximum-age limit.
2Idle transactionscount(*) WHERE state = 'idle in transaction' AND now() - state_change > interval '30 seconds'The same lesson uses one second. Thirty seconds is a tunable example.
3Lock waiterscount(*) WHERE wait_event_type = 'Lock'Who is blocking whom demonstrates one row-lock waiter; count alone does not identify a root cause.
4Increasing deadlock rateChanges in pg_stat_database.deadlocks over collection timeLogs & counters asserts a delta of one. Handle counter resets and collection gaps.
5Rising dead-row estimates or old vacuum timestampsn_dead_tup / greatest(n_live_tup, 1)::numeric, now() - last_autovacuumVacuum health demonstrates manual vacuum and estimates. Use numeric division, handle null timestamps, and investigate rather than diagnose from the ratio alone.
6Rising xid ageExample warning at age(datfrozenxid) > current_setting('autovacuum_freeze_max_age')::int / 2Vacuum health checks below the full launch threshold. Half is advice, not the wraparound boundary or a prevention guarantee.

Signals 1 through 3 can occur together, but a transaction need not hold a conflicting lock and a lock queue need not originate in an idle transaction. A full application pool is not measured by these database examples. Investigate the actual waits and application connection use before assigning a common cause.

Choose warning levels from workload needs, growth rates, monitoring privileges, and response time. A stale last_autovacuum value does not mean vacuum never ran, and a fresh one does not prove all cleanup succeeded. Counter rates need reset handling; xid age benefits from a trend and table-level investigation as well as a warning threshold.

The timeout controls and DDL lock timeout can bound specific work or waits at the cost of errors or terminated sessions. Lock-wait logging supplies diagnostics, not prevention. None of these settings guarantees an alert will not fire.

Further reading ​

MIT Licensed · Every transcript on this site was generated by a real database run against MySQL 8.4.11 and PostgreSQL 18.6 at 8fa27b8; shared YAML has an independent psycopg/PyMySQL check.