Can GROUP BY still be optimized after all these years?
Pivot describes pruning whole aggregate partitions for GROUP BY … ORDER BY COUNT(*) DESC LIMIT k using hash-bucket counts as upper bounds. If every bucket in a partition is below the current top-k threshold, no group in that partition can enter the result, so the merge can be skipped.
The authors report a ClickBench example improving from 35.6 ms to 22.2 ms while pruning over 70% of partitions; flat distributions may not benefit, and these are vendor measurements. HN readers compared the structure to a count-min sketch and discussed network costs versus horizontal scaling.