Database internals / Beginner / 5 min / Updated
Row store vs column store: OLTP vs analytics queries
The same table stored by row and by column. Load one order or sum revenue over 100 million rows and see how many bytes each layout reads.
Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.
In short
What is row vs column store?
A row store keeps each row together; a column store keeps each column together and compresses it.
Why does it matter?
Apps fetch whole records; analytics scans a few columns over billions of rows.
What is the trade-off?
Row stores are fast for single records and updates; column stores are fast for scans but slow for point writes.
How do you explain it in an interview?
"Postgres for the app, CDC into a columnar warehouse or ClickHouse for dashboards."
Check yourself
Why is a column store fast for "sum revenue per month"?
Answer: It reads only the date and amount columns, which also compress well. A row store must read every field of every row; a column store reads just the needed columns.
Which query favours a row store?
Answer: Loading all fields of one order by id. All of one row is stored together, so it is one small read; a column store visits every column.
Why do column stores compress so well?
Answer: Values in one column are similar, so encodings like run-length and dictionary work well. Compression multiplies the scan advantage: fewer bytes from disk per query.