Quick revision
The short answer
A row store keeps all columns of a row together on a page, which is ideal for reading or changing whole rows by key, the typical OLTP pattern; a column store keeps each column's values together, so a query reads only the columns it needs, and values of one type compress extremely well. SUM(amount) over 500 million rows is fast in a column store because it reads one compressed column and aggregates it in vectorized batches, instead of reading every column of every row. Updating one order is slower there because the row is spread over many column files or segments, so the change needs delete markers and new values that are merged later.
What to remember
In this answer, we saw that row stores keep whole rows together, which suits OLTP reads and writes by key, while column stores keep each column together, so analytical queries read only the columns they need. SUM(amount) over 500 million rows is fast in a column store because it reads one compressed column, skips blocks using statistics and aggregates in vectorized batches. A single-row update is slow there because the row is spread over many compressed column blocks, so it becomes a delete marker plus a new version merged later. PostgreSQL and InnoDB are row stores; ClickHouse, DuckDB, Snowflake, BigQuery and Parquet are columnar.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A row store keeps all columns of a row together on a page, which is ideal for reading or changing whole rows by key, the typical OLTP pattern; a column store keeps each column's values together, so a query reads only the columns it needs, and values of one type compress extremely well. SUM(amount) over 500 million rows is fast in a column store because it reads one compressed column and aggregates it in vectorized batches, instead of reading every column of every row. Updating one order is slower there because the row is spread over many column files or segments, so the change needs delete markers and new values that are merged later.
Background to this question
Many Java services end up with both kinds of database: PostgreSQL or MySQL for the application, and ClickHouse, Snowflake, BigQuery or Parquet files for analytics. Choosing the right one for a workload, and explaining why a report that takes minutes in PostgreSQL takes a second elsewhere, requires understanding how data is laid out on disk. In this answer, we will compare the two layouts with a concrete table, see why the column layout makes the aggregate fast through less I/O, compression and vectorized execution, explain why single-row updates are slow, and look at where each kind of store is used.
1Two Ways to Lay Out the Same Table
Take a sales table with columns id, order_id, customer_id, product_id, sold_at, quantity, amount and a few text columns, about 100 bytes per row. A row store, such as PostgreSQL or InnoDB, writes each row as one contiguous record and packs records into 8 or 16 KB pages: page 1 holds rows 1 to 70 with all their columns, page 2 the next 70, and so on. Finding order 123 means finding its page through an index and reading one page.
A column store writes each column separately. All the amount values are stored together, in row order, then all the sold_at values, and so on, usually in large blocks or segments of many thousands of values per column. The row with id 123 still exists, but its values are scattered over as many places as there are columns, tied together by their position.
| Row store page | Column store blocks | |
|---|---|---|
| what sits together | (1, 501, 77, 3, ..., 19.99) (2, 502, ...) | amount: 19.99, 5.00, 19.99, ... |
| read for one order | 1 page with all columns | 1 block from each column |
read for SUM(amount) | every page of the table | only the amount column |
| compression | modest, mixed types | high, one type and similar values |
2Why SUM(amount) Is So Much Faster
In the row store, SUM(amount) over 500 million rows must read every page of the table, because each page holds amounts mixed with all the other columns. At about 100 bytes per row, that is roughly 50 GB of pages to read, of which only 8 bytes per row are useful.
The column store reads only the amount column, 500 million values of 8 bytes, which is 4 GB before compression. Then compression shrinks it further. Values of one type that change little compress very well: run-length encoding stores a repeated value once with a count, dictionary encoding replaces repeated strings or values with small integer codes, and delta encoding stores the differences between neighbouring values. Amounts often compress to a fraction of their size, so the scan might read 1 GB or less, fifty times less than the row store.
The same idea explains why a filter like WHERE sold_at >= '2026-01-01' is cheap: the engine reads only the sold_at column to find matching positions, and each block usually has min and max statistics, so whole blocks outside the range are skipped without being read.
3Vectorized Execution
Less I/O is half of the story. Row stores usually process one row at a time: fetch a row, extract amount, add it, fetch the next row, with function calls and branches for every row. Column stores process values in batches of thousands, vectors, with tight loops over arrays of the same type. Modern CPUs run such loops very efficiently, using SIMD instructions that add several values in one instruction and keeping data in CPU caches. Some engines even aggregate directly on compressed data, for example multiplying a run-length value by its count.
Together, reading a fraction of the bytes and processing them in vectors is why an aggregate over hundreds of millions of rows can finish in about a second on a column store, while the row store spends minutes reading pages.
4Why Updating One Order Is Slower
Now reverse the workload: UPDATE sales SET amount = 21.50 WHERE id = 123. In a row store this is one page: find it through the primary key index, change the row, write a WAL record. In a column store the row is spread across many column blocks, each compressed together with thousands of other values. Rewriting a compressed block to change one value would be very expensive.
So column stores avoid in-place changes. A typical approach marks the old row as deleted, in a delete bitmap or a deletion marker, and writes the new version into a new, small segment; background merges later rewrite segments without the deleted rows, similar to compaction in an LSM tree. Reads must check the delete markers until the merge happens. That makes single-row updates and deletes slow and heavy compared with a row store, and frequent small updates can produce many small segments. Column stores are therefore built for bulk inserts and occasional bulk changes, not for an OLTP stream of individual updates.
- Find the row's positionvia primary key or sort order
- Mark the old row deleteddelete bitmap or marker
- Write the new row versioninto a new small segment, all columns
- Reads check delete markersuntil segments are merged
- Background mergerewrites segments without deleted rows
5 steps in order. Play them, or step through them one at a time.
5Where Each Is Used
PostgreSQL and MySQL InnoDB are row stores, built for OLTP: many small transactions that read and write whole rows by key. ClickHouse, DuckDB, Snowflake, BigQuery and Amazon Redshift are columnar, built for analytics over large data, and Apache Parquet and ORC are columnar file formats used in data lakes. Some systems mix the two, for example columnar extensions for PostgreSQL or databases that keep a row store for writes and a columnar copy for analytics. A common architecture is to keep the application on a row store and feed a column store through change data capture or batch exports for reporting.
6Follow-up questions
What is late materialization?
Materialization means assembling full rows from their column values. A column store with late materialization works with column positions as long as possible: it evaluates filters on one column, produces a list of matching row positions, uses that list to read only the needed values of the next column, and builds full rows only at the end, for the rows that survive. That avoids reading and decompressing values for rows that would be filtered out anyway. Early materialization would build rows first and lose much of the column layout's advantage.
Why is SELECT * slow in a column store?
Because it asks for every column, so the engine must read and decompress every column's blocks and stitch the values back into rows. The column layout pays off when queries touch a few columns of many rows, not all columns of a few rows.
Can PostgreSQL be made fast for such aggregates?
Partly. Partitioning, BRIN indexes, parallel query, covering indexes and pre-aggregated summary tables help a lot, and columnar extensions exist. But for large ad hoc analytics a columnar engine usually remains far faster, so many teams replicate data to one.
7Conclusion
In this answer, we saw that row stores keep whole rows together, which suits OLTP reads and writes by key, while column stores keep each column together, so analytical queries read only the columns they need. SUM(amount) over 500 million rows is fast in a column store because it reads one compressed column, skips blocks using statistics and aggregates in vectorized batches. A single-row update is slow there because the row is spread over many compressed column blocks, so it becomes a delete marker plus a new version merged later. PostgreSQL and InnoDB are row stores; ClickHouse, DuckDB, Snowflake, BigQuery and Parquet are columnar.
Open with
The difference is what sits next to what on disk. A row store like PostgreSQL or InnoDB keeps all the columns of a row together in a page, so finding or changing one order by key is one page read and one page change, which is exactly what OLTP needs.
Then, if they want more
A column store keeps all the values of each column together, in large blocks. For SUM of amount over 500 million rows, a row store has to read every page, about 50 GB if rows are 100 bytes, just to use 8 bytes per row.
The column store reads only the amount column, 4 GB raw, and because values of one type next to each other compress very well with run-length, dictionary or delta encoding, maybe a gigabyte.
Block statistics let it skip blocks that do not match a filter, and it processes values in vectors of thousands with SIMD instead of row by row, so the aggregate takes about a second. The flip side is updates.
One order's values are spread over many compressed column blocks, and rewriting those blocks for one value is expensive, so column stores mark the old row deleted, write the new version into a new segment and merge later. Reads have to check the markers until then, and lots of small updates hurt.
So I use PostgreSQL or MySQL for the application, and ClickHouse, DuckDB, Snowflake, BigQuery or Parquet files for analytics, usually fed by CDC or batch exports.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Explain the difference between row-oriented and column-oriented storage. Why is SELECT...": https://scrivio-interview-library.netlify.app/databases/storage-internals/0b4ded0745/