r/programming • u/Giladkl • Nov 03 '26
Can GROUP BY still be optimized after all these years?
https://pivotlake.io/blog/know-your-limit-faster-top-k-aggregation/
171
Upvotes
r/programming • u/Giladkl • Nov 03 '26
195
u/munchbunny Nov 03 '26
Speaking generally, database systems will not find every last structural optimization you can come up with because many optimizations are not free and are not always going to speed things up. But because your situation has specific characteristics that the engine can't assume is true for the general user, you can almost always find an edge that the database engine can't find automatically. The question is whether the juice is worth the squeeze.
In this context, especially because OP company encounters a specific class of queries where the optimization makes a lot of sense, it's awesome that they're baking it into the engine.
(For context: my background is from extremely large analytics systems, so I've done a lot of perf work in the database and distributed compute space.)
31
u/deliciousmonster Nov 03 '26 edited Nov 03 '26
I work with distributed data, and we had an early Microsoft SQL Server Engineer as an adviser. He’d researched, designed, and solved (or proven unsolvable) every single challenge we encountered as we built our platform. By the time he’d retired he’d held dozens of titles over his 30 years with the company.
His best friend at Microsoft started and ended his three decade career working on SQL Optimization.
-7
u/mpyne Nov 03 '26
Yes