The Engine Under the Hood
DuckDB is built on six core concepts. Understanding them gives you the vocabulary to reason about why analytical queries run fast, how DuckDB maximizes modern hardware, and what trade-offs it makes compared to traditional row-oriented databases.
Columnar Storage
DuckDB stores data by column rather than by row. Instead of keeping each row's fields together on disk, it groups all values of a single column contiguously.
Why it matters: Analytical queries typically scan millions of rows but only access a handful of columns (SELECT AVG(price) FROM sales). Columnar storage means DuckDB reads only the columns you need, skipping everything else. It also compresses dramatically better because similar values (all integers, all dates) are stored together.
Vectorized Execution
Instead of processing data one row at a time (like traditional databases) or one entire column at a time, DuckDB processes data in small batches called "vectors" — typically 2048 values at once.
Why it matters: Modern CPUs have small, ultra-fast memory caches (L1 cache/L2). A vector of 2048 values fits neatly in these caches, so the CPU can process the entire batch without waiting for slower main memory. The compiler can also auto-vectorize these tight loops into SIMD instructions, processing multiple values in a single CPU cycle.
DataChunk
A DataChunk is DuckDB's fundamental unit of data in the execution engine — a collection of vectors (one per column) that all have the same number of rows. It's the "tray" that moves through the query pipeline.
Why it matters: The DataChunk is the interface between every operator in the query pipeline. Every scan, filter, join, and aggregation works by receiving DataChunks, transforming them, and passing them forward. This uniform interface keeps the engine modular and cache-friendly.
Pipeline (Push-Based Execution)
DuckDB uses a push-based execution model where data flows from source operators through intermediate operators to sink operators. A source pushes DataChunks downstream rather than a sink pulling them.
Why it matters: Push-based execution enables morsel-driven parallelism. Multiple worker threads can each take a "morsel" (a chunk of input data) from the source and push it through the pipeline independently. This scales linearly with CPU cores without requiring explicit parallel programming.
Zone Maps (Min-Max Indexes)
For every column in every row group, DuckDB automatically tracks the minimum and maximum values. These metadata statistics are called zone maps.
Why it matters: Zone maps provide free query acceleration for filtered scans. A query like WHERE date > '2025-01-01' on a time-ordered dataset can skip most row groups by just checking the min/max metadata — potentially eliminating 99% of I/O before reading a single data value.
Row Groups
DuckDB organizes table data into row groups — horizontal partitions of roughly 122,880 rows each. Each row group stores its columns independently with separate compression, statistics, and zone maps.
Why it matters: Row groups are the unit of parallelism and I/O. Different threads can process different row groups concurrently. The size is chosen to balance between parallelism granularity and metadata overhead — large enough to amortize per-group costs, small enough to enable effective pruning and parallel scanning.
How They Fit Together
When you run a SQL query, all six concepts work in concert. Here's the journey your query takes from text to results: