Database Execution Engines: From Plans to Pipelines
The execution layer
Most computer systems can be viewed as a separation of computation and control, I/O, and storage. In a database kernel, those responsibilities map roughly to the execution engine, the RPC layer, and the storage engine. The execution engine is where a user request becomes work: it evaluates the request, coordinates operators, and produces results. This article introduces the basic structure and runtime model of a modern database execution engine.
Expressions, logical plans, and physical plans
Query execution is a staged transformation with three important levels: expressions, a logical plan, and a physical plan.
- An expression is the smallest unit of computation, such as
a + borc > 10. It describes a computation over values or columns. - A logical plan combines expressions to describe the semantics of a query: Filter, Join, and Project, for example. It does not commit to a particular implementation.
- A physical plan chooses the concrete execution path. It specifies strategies such as a hash join or a nested-loop join, together with physical operators and their cost model.
The progression is therefore: expression → logical plan → physical plan.
Pipelines and operators: the runtime for a physical plan
A physical plan still needs a runtime representation that can perform the underlying work. Modern database engines commonly use a pipeline-and-operator model. They decompose a plan into operators with clear responsibilities—Scan, Filter, Project, and Aggregation—and connect them into a pipeline that can execute continuously with limited intermediate materialization.
In query processing, materialization means explicitly storing an intermediate result in a medium such as an in-memory buffer, a temporary disk file, or a network handoff. Once materialized, the result has left the active computation chain and must be fetched or read by a downstream operator.
Why pipeline execution helps
- Lower peak memory use. A pipeline does not eliminate materialization entirely. Instead, it reduces it to small batches such as
RowVectors. A batch can be released as soon as its consumer finishes with it, which shortens the lifetime of intermediate data. The effect is especially useful when a downstream operator rejects many rows, such as a selective Filter or an early-terminating Limit. A simple full-table projection is different: every row still has to be processed and passed downstream, so the memory advantage is much smaller.
- More execution overlap and earlier results. Operators in a pipeline can overlap: an upstream operator can produce one batch while the next operator consumes it. In a pipeline without blocking operators, a driver-driven asynchronous pipeline can expose concurrency comparable to the number of operators. The first batches can also reach the caller sooner.
- Better cache locality. A
RowVectorholds a small batch rather than an entire intermediate result, making it more likely to remain in CPU caches. If an engine first materializes every row and later rereads the result, early batches may already have been evicted by the time downstream processing begins, increasing cache misses.
RowVector: the data exchanged between operators
Operators do not normally exchange records one at a time. They exchange a vector of records called a RowVector. It is a column-oriented, row-assembled structure: a RowVector contains multiple ColumnVectors, each holding a batch for one column, and all columns share a batch size. A RowVector with int_a, float_b, and string_c, for example, stores one batch for each of those columns. A ColumnVector for float_b can be loaded directly into an AVX/SSE register for SIMD computation.
This layout improves CPU-cache use and SIMD utilization. Processing multiple rows per call also reduces function-call frequency and context-switch overhead compared with row-at-a-time execution. It gives operations such as filtering and projection a more efficient execution model.
A linear pipeline
A simple query maps to one linear pipeline with non-blocking handoffs between operators:
SELECT a, b FROM t WHERE c = 10;
Its operator chain is TableScan → Filter → Project. A driver pulls data through the pipeline: TableScan produces RowVectors, Filter evaluates c = 10 for each batch, and Project selects a and b for output.
Crossing a blocking boundary
Joins, aggregations, and sorts force an engine to split a pipeline. Some operators must finish an entire input before downstream work can begin. The build side of a hash join is a common example:
SELECT t1.a, t2.b FROM t1 JOIN t2 ON t1.id = t2.id;
The engine can represent this query as two pipelines:
- Pipeline 1 (build side):
TableScan(t2) → HashBuild - Pipeline 2 (probe and project side):
TableScan(t1) → HashProbe → Project
The first pipeline must construct the hash table for t2 before the second can probe it with rows from t1. These crossings and blocking points are central concerns for an engine scheduler and optimizer.
Takeaway
The execution engine sits between storage and query semantics. Its job is not merely to run SQL, but to manage operator flow, schedule resources, and maintain performance. Pipelines composed of operators, with RowVectors as the exchange format, are a widely used foundation for streaming execution in modern database engines.
— MrPresent-Han


