Performance debugging starts with the data, not the guess
The first instinct on a slow system is to add an index, increase the cache, or rewrite the query. The professional instinct is to measure first: which query is slow, when, how often, and by how much. Without numbers, every change is a guess and most guesses make things worse.
The two diagnosis dimensions
- Query-level — which query is the offender?
pg_stat_statementsranks every query by total time, mean time, call count. - Wait-level — what is the database waiting on?
pg_stat_activityshows live queries and what they're waiting for (locks, IO, CPU).
The mental ranking
Order of suspicion: (1) missing index, (2) lock contention, (3) bloat / dead tuples, (4) cache pressure / disk IO, (5) network / pooling. Almost every "the database is slow" incident lands somewhere in this list.