Skip to content

Lab 10 — Incident Diagnosis

Scenario

Instead of beginning with one query, you begin with database-wide signals. pg_stat_statements identifies cumulative workload, while pg_stat_activity shows what sessions are doing now.

Run the exercise

make shell
\i sql/labs/10-incidents/bad_queries.sql

Investigate

  1. Separate high total time from high mean latency and high call count.
  2. Treat cumulative statistics as evidence with an unknown observation window unless reset time is known.
  3. Correlate active queries with state and wait events.
  4. Capture query IDs and representative plans before changing anything.
  5. Rank hypotheses and state what evidence would reject each one.

Diagnostic question

Which workload deserves investigation first, and how do you distinguish an expensive query from a frequently called query or a waiting session?

Previous: Partitioning · Next: Concurrency