What is a columnar database?
A columnar database stores the values of each column together on disk, instead of storing each row together. Analytical queries then read only the columns they need and compress far better, at the cost of slower single-row inserts and updates.
Row storage and column storage
A row store such as PostgreSQL or MySQL writes a table one row at a time: id, customer, amount, date, then the next row. That layout is ideal for fetching or updating one order. A column store writes all the ids together, then all the amounts, then all the dates. Asking for the total amount of every order means reading one tightly packed column and skipping the rest.
| Row store | Column store | |
|---|---|---|
| Stores together | All fields of one row | All values of one column |
| Good at | Reading or changing single rows | Scanning, filtering and aggregating many rows |
| Reads for SUM(amount) | Every column of every row | Only the amount column |
| Compression | Modest: mixed types side by side | High: similar values side by side |
| Examples | PostgreSQL, MySQL, SQL Server, Oracle | DuckDB, ClickHouse, BigQuery, Snowflake, Parquet files |
Why analytical queries run faster on columns
- Less to read. A query that touches 3 of 40 columns reads roughly 3/40 of the data.
- Better compression. A column holds one type and often repeats values, so dictionary and run-length encoding shrink it by large factors, and less data means less I/O.
- Vectorized execution. Engines like DuckDB process a column in batches of a few thousand values with tight CPU loops, instead of one row at a time.
- Skipping. Column stores keep min and max values per block, so a filter like order_date >= '2026-10-01' skips whole blocks without reading them.
An example in DuckDB
DuckDB is a columnar engine. This builds a 10-million-row table with a wide text column, writes it to Parquet (a columnar file format), and shows how each column is stored.
CREATE TABLE orders AS
SELECT range AS id,
range % 1000 AS customer_id,
round(random() * 100, 2)::DECIMAL(10,2) AS amount,
DATE '2026-01-01' + (range % 365)::INT AS order_date,
repeat('x', 200) AS notes
FROM range(10_000_000);
COPY orders TO 'orders.parquet' (FORMAT parquet);
-- Reads only the amount column from the file, not notes or id
SELECT sum(amount) FROM 'orders.parquet';
-- Compressed size of each column in the first row group
SELECT path_in_schema, total_compressed_size
FROM parquet_metadata('orders.parquet')
WHERE row_group_id = 0;On a laptop the sum over 10 million rows returns in about 10 milliseconds. In the metadata, the 200-character notes column, the same value repeated, compresses to 67 bytes per row group, while the unique id column takes about 490 KB. A row store would carry those 200 characters in every row it reads.
When a row store is the better choice
Applications that insert, update and look up individual records, such as orders, users or sessions, belong in a row store. Changing one row in a column store means touching every column file, and most column stores batch writes for that reason. The usual split is a row store for the application and a column store for analytics. See OLAP vs OLTP.
In Thunderduck
Every Thunderduck query runs on DuckDB, a columnar, vectorized engine, in its own worker. Parquet and Iceberg files in S3, GCS, Azure or R2 are read column by column, so a query fetches only the columns and row groups it needs. PostgreSQL and MySQL are row stores, so for those Thunderduck sends the filters to the source instead and reads back only the matching rows (see predicate pushdown).
Docs: https://docs.thunderduck.ai/data/reading-files/