Quick revision
The short answer
A column store keeps each column's values together, so SUM(amount) grouped by region reads only those two columns instead of every full row. Values of one column are similar and compress very well with dictionary, run-length and delta encoding, which cuts the bytes read further, and vectorised execution processes batches of values in tight CPU-friendly loops. Min and max metadata per block lets the engine skip data that cannot match a filter. The same layout makes single-row lookups and frequent updates slow, which is why row stores like PostgreSQL remain better for transactional work.
What to remember
In this answer, we saw why a column store answers SUM(amount) GROUP BY region over two billion rows far faster than a row store. It reads only the two needed columns instead of whole rows, compresses each column with dictionary, run-length and delta encoding so it reads a few gigabytes instead of hundreds, processes values in vectorised batches that suit modern CPUs, and skips blocks using min and max metadata. The price is slow single-row lookups and updates, which is why row stores remain the right choice for transactional work.
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 column store keeps each column's values together, so SUM(amount) grouped by region reads only those two columns instead of every full row. Values of one column are similar and compress very well with dictionary, run-length and delta encoding, which cuts the bytes read further, and vectorised execution processes batches of values in tight CPU-friendly loops. Min and max metadata per block lets the engine skip data that cannot match a filter. The same layout makes single-row lookups and frequent updates slow, which is why row stores like PostgreSQL remain better for transactional work.
Why this question is asked
The same question, total sales per region, can take a quarter of an hour on a large PostgreSQL table and a few seconds on a column-oriented warehouse running on comparable hardware. Interviewers ask why because the answer explains when to move analytics off the operational database, and because it tests whether we understand that storage layout, not magic, decides speed. In this answer, we will compare how a row store and a column store lay out the sales table, count the bytes each must read, and then go through compression, vectorised execution and data skipping, before looking at what column stores are bad at.
1How a Row Store Lays Out the Data
PostgreSQL stores a table as 8 KB pages, and each page holds complete rows one after another: id, sale_date, customer_id, product_id, region, amount, and perhaps twenty more columns, then the next row. That layout is ideal for transactional work, where we usually read or write one whole row at a time, such as fetching order 501 by its primary key.
For our query, it is wasteful. To sum amount by region, PostgreSQL must read every page of the table, because each page mixes all columns of the rows it holds. Suppose a row is 200 bytes on disk. Two billion rows are then about 400 GB, and a sequential scan reads all 400 GB even though the query needs only two small columns.
2Reading Only the Columns We Need
A column store turns the layout around. Each column of the table is stored separately, in large blocks that hold thousands to millions of values of that one column. The region values of all rows sit together, and so do the amounts. The query reads the region blocks and the amount blocks and never touches the other 23 columns.
Without any compression, region as a short text of about 8 bytes and amount as an 8-byte number are 16 bytes per row, or 32 GB for two billion rows. That is already twelve times less than the row store's 400 GB, purely from layout.
| Step | Row store | Column store |
|---|---|---|
| Columns read | all 25 (whole rows) | 2 (region, amount) |
| Raw bytes read | about 400 GB | about 32 GB |
| After compression | table mostly uncompressed | a few GB |
| Blocks skipped by min/max | none without an index | many, when a filter is present |
| Execution | one row at a time | batches of thousands of values |
3Compression: Similar Values Compress Well
Storing a column on its own has a second benefit: its values are all of one type and often very repetitive, and that compresses far better than mixed rows. Column stores pick an encoding per block. Dictionary encoding replaces each distinct value with a small integer: with ten regions, every region becomes a code that fits in 4 bits instead of an 8-byte string. Run-length encoding stores a value and how many times it repeats, which is extremely effective when data is sorted, as region often is within a partition. Delta encoding stores the difference from the previous value, useful for dates and increasing ids, where the differences are tiny numbers.
After encoding and general-purpose compression, two billion region values might take around 1 GB and the amounts a few GB, so the query reads a few gigabytes instead of 400. Less data read means less disk and network I/O, which is usually the slowest part of an analytical query.
4Vectorised Execution
A traditional row-at-a-time executor, like PostgreSQL's, calls a function for each row to fetch the next tuple, extract the columns, evaluate the expression and update the aggregate. For two billion rows, that overhead of function calls and branches dominates the time, even when the data is in memory.
Column stores use vectorised execution: operators work on batches, for example 1,024 or several thousand values of a column at a time. Summing a batch of amounts is a tight loop over an array, which modern CPUs execute very fast, keep in cache and can even run with SIMD instructions that process several values in one instruction. Some engines even aggregate directly on dictionary codes without decoding them. The result is that each CPU core processes hundreds of millions of values per second, and the warehouse spreads the work across many cores and often many machines.
5Data Skipping With Min and Max Metadata
Our example query has no filter, but most real queries do, such as WHERE sale_date >= '2026-10-01'. Column stores keep small metadata for each block or micro-partition, the minimum and maximum value of each column in it. Before reading a block, the engine checks whether the range can match the filter. A block whose sale_date runs from 2025-01-03 to 2025-01-09 cannot contain October 2026, so it is skipped without being read.
This works best when data is sorted or clustered by the filtered column, which is why warehouses let us cluster or partition tables by date. It gives much of the benefit of an index, without maintaining one.
6What Column Stores Are Bad At
The same layout has a cost. Fetching one complete row, such as SELECT * FROM sales WHERE id = 123, means visiting a block in each of the 25 columns and decompressing them, which is far slower than reading one row from a page through a B-tree index. Updating one row is worse: compressed blocks cannot easily be changed in place, so engines mark rows deleted and write new versions in separate structures, merging them later. Frequent small updates and many concurrent short transactions are exactly what an operational system needs, and what row stores such as PostgreSQL handle well.
So the two designs complement each other. The operational database keeps rows for transactions, and a column store receives the data, usually in batches or through CDC, for analysis.
7Follow-up questions
Can PostgreSQL get some of these benefits?
Partly. Parallel sequential scans and BRIN indexes, which store min and max per range of pages, help on large tables, and columnar extensions add column-oriented table storage. For billions of rows of heavy aggregation, a dedicated column store or warehouse is still usually much faster.
Why are column stores often loaded in batches?
Because compression and min and max metadata work best on large, full blocks. Many single-row inserts would create tiny blocks, so engines buffer incoming rows and write them as large compressed blocks, or compact small ones later.
Does SELECT * hurt in a column store?
Yes, much more than in a row store. Every additional column means more blocks to read and decompress, so naming only the needed columns is one of the simplest ways to make warehouse queries faster and cheaper, especially where pricing depends on bytes scanned.
8Conclusion
In this answer, we saw why a column store answers SUM(amount) GROUP BY region over two billion rows far faster than a row store. It reads only the two needed columns instead of whole rows, compresses each column with dictionary, run-length and delta encoding so it reads a few gigabytes instead of hundreds, processes values in vectorised batches that suit modern CPUs, and skips blocks using min and max metadata. The price is slow single-row lookups and updates, which is why row stores remain the right choice for transactional work.
Open with
The main reason is layout. PostgreSQL stores whole rows together in pages, so to sum amount by region it has to read every page of the table, all 25 columns, maybe 400 GB for two billion rows, even though it needs two columns.
Then, if they want more
A column store keeps each column separately, so it reads only region and amount. That alone is more than ten times less data. Then compression multiplies the gain: a column's values are similar, so region becomes dictionary codes of a few bits, sorted runs compress with run-length encoding, and dates and ids compress with delta encoding.
We end up reading a few gigabytes. Third, execution is vectorised: operators process batches of thousands of values in tight loops, which suits CPU caches and SIMD, instead of PostgreSQL's row-at-a-time function calls.
Fourth, column stores keep min and max values per block or micro-partition, so with a filter like a date range they skip blocks that can't match, which works best when the table is clustered by that column. And it's parallel across many cores or machines.
The trade-off is that single-row lookups and frequent updates are slow, because a row is spread across many compressed blocks. So PostgreSQL stays the right choice for transactions, and the warehouse gets the data for analytics.
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 "Why are column-oriented warehouses faster than a row store like PostgreSQL for a query...": https://scrivio-interview-library.netlify.app/databases/analytics-and-cdc/6ac13f9266/