aligputf8=# explain analyze select sum(col1),sum(col2),sum(col3),sum(col4),sum(col5),sum(col6),sum(col7),sum(col8),sum(col9), max(col1),max(col2),max(col3),max(col4),max(col5),max(col6),max(col7),max(col8),max(col9), avg(col1),avg(col2),avg(col3),avg(col4),avg(col5),avg(col6),avg(col7),avg(col8),avg(col9) from test_group group by id; QUERY PLAN ---------------------------------------------------------------------------------------------------- HashAggregate (cost=15225.85..29783.06 rows=108256 width=66) Group By: id Rows out: 100000 rows with 722 ms to first row, 1367 ms to end, start offset by 0.125 ms. Executor memory: 32536K bytes. Work_mem used: 32001K bytes. Work_mem wanted: 106876K bytes to lessen workfile I/O. 100000 groups total in 32 batches; 1 overflows; 100000 spill groups. Hash chain length 1.8 avg, 20 max, using 74100 of 135168 buckets. -> Seq Scan on test_group (cost=0.00..1480.56 rows=108256 width=66) Rows out: 100000 rows with 0.016 ms to first row, 51 ms to end, start offset by 0.142 ms. Slice statistics: (slice0) * Executor memory: 32697K bytes. Work_mem: 32001K bytes max, 106876K bytes wanted. Settings: enable_groupagg=off; enable_hashagg=on; enable_seqscan=off; work_mem=32000kB Total runtime: 1391.138 ms (14 rows)