Plan operator

GroupAggregate

Plan node that groups rows assuming the input is already sorted on the GROUP BY keys.

A GroupAggregate walks an input that is already sorted on the GROUP BY columns and emits one output row per group. Because every row in a group arrives consecutively, no hash table is needed — memory usage is constant in the number of groups.

The planner picks it when the input is naturally sorted (an Index Scan on the grouping columns) or when a Sort is cheap relative to building a hash. It is the right choice for very high-cardinality grouping where HashAggregate would blow work_mem.

To force a GroupAggregate, add a B-tree index covering the GROUP BY columns so the planner sees ordered input for free; otherwise it will tend to prefer HashAggregate for small group counts.