SET trace_sort TO on;
SET client_min_messages TO log;
explain analyze select id, sum(count) from sort_test group by id order by sum(count) desc limit 100
Output :
LOG: begin tuple sort: nkeys = 1, workMem = 4096, randomAccess = f
LOG: switching to bounded heapsort at 201 tuples: CPU 0.01s/1.30u sec elapsed 1.31 sec