Lab 07 — Sort and Aggregate
Scenario
A revenue leaderboard groups all orders by customer and sorts the aggregates while work_mem is limited to 2 MB. The plan may expose memory pressure and temporary I/O.
Run the exercise
Investigate
- Identify aggregate and sort strategies.
- Record sort method, memory use, batches, and temporary reads or writes.
- Determine whether the constrained
work_memaffects one or several nodes. - Test session-local settings cautiously and compare repeated plans.
- Discuss concurrency risk before recommending a global memory increase.
Diagnostic question
Did execution spill to disk, and does the evidence justify changing the query, an index, or memory configuration?