When a database stores a billion sales records, a traditional row store keeps every field for each sale together: date, product, region, amount, status â all bundled in one row. That layout is perfect for fetching a single customer's full record. But for analytics, where you want to sum the amount column across all rows, you end up reading every field just to get to the one you care about.
Column stores flip the layout. Every value of product lives next to every other product value; every status sits next to every other status. Suddenly a query that touches only two columns reads only two columns' worth of disk blocks, ignoring the rest.
The deeper gain is compression. When you read a column of sales statuses, you find the same handful of values â "confirmed", "pending", "refunded" â repeated millions of times. Row stores mix all columns together and lose that regularity; column stores expose it, and then squeeze it hard.
The three workhorses that do the squeezing are run-length encoding (RLE), dictionary encoding, and bit-packing â three elegant ideas that together can shrink a column to a fraction of its original size, sometimes 10Ă or more.
Comments
Loading comments...