Can GROUP BY still be optimized after all these years?

ntur1337 125 points 28 comments November 03, 2026
pivotlake.io · View on Hacker News

Discussion Highlights (8 comments)

toddbandrowsky

You know, I have a hard time seeing how it can be cheaper to run a dataset across a wire rather than just send its grouped results. That's really the problem. I mean, who cares if it takes 100ns to group by on a box when it will take 10 times much for the data to get to it and back. The fastest possible group by is in sequential memory on that box, fetched from an nvme. So, when we do group by partitioning, we're really saying, put the groups themselves on different boxes, and group the group by. If it were some utter megaset, the place to put it is on a mainframe, which is basically created for purposes of group by on ridiculous datasets.

ozgrakkurt

Their clickbench results look really good. https://benchmark.clickhouse.com/#system=+liH|Hoaus|DcD|ucqs...

shikck200

More importantly, WHY is mysql GROUP BY still broken as default? MySQL is the PHP of databases, but it seems they have no plan to fix bugs.

malisper

Neat! For others, the data structure they are describing is a count-min sketch. It looks like they're using it to set a bound on elements that can enter the group-by and using it to skip a bunch of extra work

misiek08

22.2ms vs 35.6ms is 1.6x faster! It's 0.4x faster and even doing worst math possible it's 0.62x faster. Can't we really keep the IT without breaking news/we are all gonna die/sensationalist way of passing news?

holoduke

I wonder if with a LLM you could better analyse and make a strategy for querying. Maybe even live restructuring of data models based on its usage.

SkiFire13

I wonder why you didn't opt to perform a Top-K aggregation in each partition in parallel. That would give you both a reduction of elements in each partition and also the correct maximum of each partition, which can be used for further pruning.

eden-u4

What's the difference between pivot and duckdb? They seem rather similar and this implementation of group by may be copied by other to achieve similar bench results

Semantic search powered by Rivestack pgvector
3,874 stories · 35,194 chunks indexed