Why are grouped aggregate functions on a columnstore index fast?
4
votes
1
answer
97
views
Suppose that a table only contains integers and has a clustered columnstore index.
CREATE TABLE cci_account
(
AccountKey int NOT NULL,
UnitSold int,
INDEX ColStore CLUSTERED COLUMNSTORE
);
then it appears that summing one column grouped by another is always fast on such a table, e.g.
SELECT
AccountKey,
SUM(UnitSold)
FROM
cci_account
GROUP BY
AccountKey;
Why is this so fast? My understanding of the columnstore architecture is that the segments containing AccountKey
have no idea what UnitSold
value is on their rows. How, then, is SQL Server able to so quickly group by AccountKey
? I cannot imagine any algorithm that would achieve this.
Asked by J. Mini
(1237 rep)
Jan 1, 2025, 07:18 PM
Last activity: Jan 2, 2025, 03:55 PM
Last activity: Jan 2, 2025, 03:55 PM