← Tue, Nov 17 digest

Rows vs. Columns: How different are they, really?

read article ↗ hn thread ↗

Connor Tsui details the physical, architectural, and hardware-level differences between row-oriented and column-oriented database storage layouts.

read it It provides a clear, hardware-level breakdown of how row and column stores differ in memory layout, cache usage, vectorization, and compression.

summary

The article compares row stores and column stores by examining how data is arranged in memory and on disk. It demonstrates why analytical queries benefit from columnar layouts through efficient CPU cache utilization, vectorization, and SIMD instruction autovectorization. Additionally, it highlights how lightweight encodings enable high compression ratios while preserving random access. Ultimately, these physical design choices explain why databases are typically optimized for either transactions or analytics, but rarely both.

key points

  1. Row stores optimize for single-record access, whereas column stores optimize for scanning subsets of attributes across large datasets.
  2. Columnar layouts allow hardware to leverage SIMD instructions and better CPU cache locality during vectorized execution loops.
  3. Unlike black-box compression, lightweight encodings on columnar data preserve random access and allow compute operations directly on compressed values.

who should read it

Backend engineers and database developers looking to understand the low-level hardware implications of storage engine design.

discussion warm

consensus

Commenters appreciate the clear conceptual grounding and note the direct parallel to Array of Structures versus Structure of Arrays in systems programming.

pushback

Some commenters point out nuances around clustered indexes and index-only scans, arguing that row stores can sometimes achieve column-like scan efficiencies for specific queries.

best comment by reticulates ↗

> Those consequences are the reason that most database systems are built for either transactions or analytics, and not both. [24]

> [...]

> [24] People have tried to build one system that does both in the past (HTAP, or hybrid transactional/analytical processing), but those attempts generally didn't work out. Some newer systems seem to be bridging the gap, however. CedarDB, the commercial version of Umbra (a research system from TU Munich), runs transactions and analytics on just one engine and one copy of the data. Databricks' Lakebase keeps Postgres (a row store) as the engine for …

It evaluates the ongoing viability of HTAP databases like CedarDB and Lakebase trying to bridge the row-column divide.

Generated by an LLM from the article and thread. Check the sources before relying on it.