Database / DuckDB Interview questions
What is the difference between DuckDB's vectorized execution and traditional row-at-a-time execution?
Traditional row-at-a-time (or "tuple-at-a-time," Volcano-style) execution processes a query by pulling one row through the entire operator pipeline before moving to the next row, calling a next()-style function repeatedly for every single row. This is simple to implement and reason about, but the per-row function call and branching overhead becomes a significant cost relative to the actual work being done, especially for simple operations like a basic filter or arithmetic expression.
| Row-at-a-time | Vectorized (DuckDB) |
| Processes one row through the pipeline at a time. | Processes a batch (vector) of rows through each pipeline stage at once. |
| High per-row function call/branching overhead relative to simple operations. | Overhead amortized across an entire batch. |
| Limited ability to leverage CPU SIMD instructions. | Well suited to SIMD and cache-friendly memory access patterns. |
Vectorized execution instead processes a batch of, typically, a few thousand rows through each operator at once, meaning the fixed overhead of moving between pipeline stages is paid once per batch rather than once per individual row, and the actual per-value computation within a batch can be structured to take advantage of modern CPU features (SIMD, cache locality) far more effectively than a row-at-a-time loop naturally allows.
More Related questions...