Plan nodes · Grouping and sorting

Group

Removes duplicate group keys from sorted input, without aggregates.

For GROUP BY with no aggregate functions: since its input is sorted on the group key, it returns one row each time the key changes.

Example

SELECT album_id FROM tracks WHERE album_id < 100 GROUP BY album_id

2 nodes

Run with EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) on the sample database, PostgreSQL 19.0. Open it in the EXPLAIN visualizer →

Related

Sort · Incremental Sort · Aggregate · Unique · WindowAgg · Limit