Database / DuckDB Interview questions
What is columnar storage, and how does DuckDB use it?
Columnar storage organizes data by column rather than by row: all values for a single column are stored contiguously, instead of a traditional row-oriented layout where all fields of a single record sit next to each other. DuckDB stores and processes data this way internally.
This layout matters enormously for analytical queries, which typically read a small number of columns out of a wide table but aggregate or scan across many rows, like SELECT AVG(price) FROM sales. A columnar engine can read only the price column from disk or memory, skipping every other column entirely, while a row-oriented engine would need to read entire rows (every column) just to extract the one field each row actually needs for that computation.
Columnar layout also compresses better in general, since values within a single column tend to be more similar to each other (repeated categories, sequential IDs, similar-magnitude numbers) than values across a mixed row, which is part of why DuckDB and other columnar analytical engines tend to achieve strong compression ratios on typical analytical datasets.
More Related questions...