News for hackers. Stuff that matters.
Re:Lesser-known Postgres features by NightMKoder on Tuesday November 09, 2021 @02:44PM (#29166470)
I assume you mean `ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...) as row_number` with a `WHERE row_number = 1`. We ran into issues with memory usage (i.e. queries erroring because of too high memory usage).

The `ARRAY_AGG` approach uses a simple heap, so it's as efficient as MIN/MAX because it can be computed in parallel. ROW_NUMBER however needs all the rows on one machine to number them properly. ARRAY_AGG combination is associative whereas ROW_NUMBER combination isn't.

Re:Lesser-known Postgres features by mnahkies on Tuesday November 09, 2021 @03:13PM (#29166860)
That makes sense, I might have a play with the array agg approach. I'm especially curious if it has any impact on slot time consumed