Exercise 3: What pg_stat_activity Revealed in the Worked Example — Possible Solution ==================================================================== WHAT THE QUERY OUTPUT ACTUALLY SHOWED ------------------------------ Per this chapter's worked example, "pg_stat_activity confirms exactly one query - a full scan of order_items with no supporting index on the column it filters by - has been running for over four minutes, while every other query on the system finishes normally." One query at over 4 minutes duration, versus every other query finishing in a couple of seconds. WHY THIS SPECIFICALLY CONFIRMS "HELD TOO LONG," NOT CAPACITY ------------------------------ Per this chapter's own distinguishing criterion, a genuine capacity problem would show many connections each held briefly, all roughly similar in duration, simply too many of them for the pool size. What was actually found is the opposite pattern: the overwhelming majority of queries are fast and normal, and only a single outlier is dramatically slower than everything else - exactly the "small number of connections held too long" pattern this chapter describes, not evenly-distributed high demand. WHY THIS MATTERS FOR THE FIX ------------------------------ Because the evidence pointed at one specific query rather than overall capacity, per this chapter, "the actual fix is adding the missing index (or rewriting the query) - not increasing the pool size, which would only mask the same problem a little longer while adding more load to an already-struggling database." Had the evidence instead shown many queries finishing quickly but total demand simply exceeding the pool's size, increasing pool size would have been the correct fix instead. WHY THIS WORKS AS AN ANSWER ------------------------------ It states the specific evidence from the query output, explains why that specific pattern (one outlier vs. many similar) matches the "held too long" category rather than capacity, and connects that diagnosis to why the resulting fix (index/query rewrite) was the correct one rather than a pool-size increase.