Field notes on columnar storage. Opinions are marked as opinions.

A row store keeps each record together on disk: order 1001, its customer, date, amount, city, status, and everything else, then order 1002, and so on. Your application database almost certainly works this way. It is a good design when the job is “fetch order 1001” or “update its status”, because everything about one order sits in one place.

A column store flips it. All the amounts sit together. All the dates sit together. All the cities sit together. Parquet and ORC files are built this way, and so are warehouses such as BigQuery, Redshift and Snowflake in how they store data internally. The exact layout differs by product, but the principle is shared.

Reading less is the whole trick

Take an orders table with 50 columns and 10 crore rows. A typical analytical question: total amount by month for the last year. That touches two columns, amount and order date. In a row store the engine reads whole rows, so it pulls all 50 columns off disk to use two. In a column store it reads just those two column chunks. Roughly 2 of 50 is 4 percent of the columns. Real savings depend on column widths and the filter, so treat 4 percent as the shape of the benefit, not a promise.

Disk and network reads are usually the slowest part of an analytical query. Cut those and you cut the time. On cloud warehouses that bill by data scanned, you cut the bill too. This is why “select star” is a bad habit on a columnar system: it asks for every column and throws away the advantage.

Similar values squeeze well

The second gain is compression. A column holds one type of thing. A “state” column with 28 or so distinct values repeated over crores of rows compresses very well using dictionary encoding: store the list of states once, then store small numbers pointing to it. A status column that is “DELIVERED” for long runs compresses even further with run-length encoding, where you store the value and how many times it repeats. In a row store, neighbouring bytes belong to unrelated fields, so none of this works as well.

Sorting matters here. If the file is sorted by date, the date column becomes tiny and the engine can also use stored minimum and maximum values for each block to skip blocks entirely. Parquet files keep such statistics per column chunk, and engines use them to avoid reading chunks that cannot match your filter. My opinion: the cheapest performance work in most analytics teams is not a bigger cluster but choosing a sensible sort or partition key and keeping files a reasonable size.

What you pay for it

Columns are bad at the job rows are good at. Fetching one complete record means gathering a piece from each of 50 column areas. Updating one value means touching a compressed block, and many columnar file formats are effectively immutable once written. To change a row, systems rewrite files or write small delta files and merge later. That is why table formats such as Delta Lake and Apache Iceberg exist: they add a transaction log on top of Parquet files so that updates, deletes and consistent reads become manageable.

Small inserts are the other pain. Writing one row per second as one file per second gives you millions of tiny files, which is slow to read and a nuisance to manage. Batches are the answer, or a compaction job that merges small files later.

A rule I use for choosing

  • Many small reads and writes of whole records, with low latency and constraints: row store.
  • Few queries that scan many rows but few columns, aggregate them, and tolerate seconds of latency: column store.
  • Both needs on the same data: keep the transactional copy in a row store and load a copy into a column store. Do not fight physics with one engine unless the vendor can show you the evidence on your workload.

Some databases offer hybrid designs, with a row-oriented store for recent writes and column-oriented storage for history. They are real and useful, but check how much each product’s claims depend on your query pattern.

Practical habits that follow

Name only the columns you need. Filter on the column the data is sorted or partitioned by. Avoid wide text blobs in the same table you aggregate. Prefer a handful of big files over many small ones. Use CSV for hand-offs to humans, and Parquet for anything a machine will scan repeatedly; a CSV has to be parsed in full, has no types, and carries no statistics.

One last caution: column stores do not make a bad question good. A query that joins two huge tables on the wrong key will still explode, whatever the layout. Storage format reduces the cost of reading. It does nothing for logic.

Figures and names in the examples are illustrative.

Leave a Reply

Trending