Querying Local Files at Lightning Speed with DuckDB
Run analytical SQL directly on local Parquet/CSV with DuckDB for fast exploration and light transforms.
In plain words
File, glob, HTTP, or object store. Next, explicit types for CSV and JSON. Finally, sorted, compressed Parquet with row checks.
Think of it like…
DuckDB is a high-speed analytical workbench bolted directly to the files, whereas a warehouse is an entire shared factory with operators, queues, and admission control.
Where you’ve seen it
duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.
Words you’ll hear
- DuckDB
- An embedded OLAP engine process that stores and executes analytical SQL close to the application.
- SQL on Files
- DuckDB's table functions that expose files such as
read_parquet()as relational inputs without a load step. - Parquet
- A path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown.
- Operational boundary
- It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling. Set
memory_limit,threads, andtemp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.
Visual diagram
Theory & deep dive
DuckDB: the working mechanism
DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service.
File, glob, HTTP, or object store. Explicit types for CSV and JSON, then filters, joins, aggregates; this exposes the state governed by Parquet.
duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.
Querying Local Files at Lightning Speed with DuckDB: failure mode and production response
It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks. Track Memory bound as "configure a fraction of host RAM with memory_limit", and make Vector size visible to the dataset owner.
memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.How it works, step by step
Step 1 of 41. Register input
File, glob, HTTP, or object store. DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service.
- Memory bound
- configure a fraction of host RAM with `memory_limit`
- SQL on Files
- DuckDB's table functions that expose files such as `read_parquet()` as relational inputs without a load step.
When to use it & trade-offs
What it is
DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service. duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.
Why it matters: It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling. Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.
When to reach for it
- Run analytical SQL directly on local Parquet/CSV with DuckDB for fast exploration and light transforms.
- Choose DuckDB because it provides this capability: An embedded OLAP engine process that stores and executes analytical SQL close to the application.
- Keep evidence for Memory bound at "configure a fraction of host RAM with
memory_limit" so the last production stage-Publish - sorted, compressed Parquet with row checks-remains testable.
When to avoid or be careful
- It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
- Do not conflate SQL on Files with DuckDB. The second concept contributes different behavior: DuckDB's table functions that expose files such as
read_parquet()as relational inputs without a load step. - Release only after this guardrail is in place: Set
memory_limit,threads, andtemp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.
DuckDB / SQL on Files / Parquet - roles, limits, and operating cost
Strengths: An embedded OLAP engine process that stores and executes analytical SQL close to the application. DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service.
Watch out: It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
read_parquet() as relational inputs without a load step.Strengths: DuckDB's table functions that expose files such as read_parquet() as relational inputs without a load step. In this workflow it supports: Run vectorized SQL - filters, joins, aggregates.
Watch out: The operating cost is real: typically about 2,048 values per vector batch.
Strengths: A path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown. Its output can be checked with Concurrency.
Watch out: Operating guardrail: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for DuckDB, and how would Memory bound reveal it?”
- “Why is SQL on Files distinct from this behavior: a path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown?”
- Production clue: It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
- Design probe: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.
Benchmarks & rules of thumb
- Memory bound
- configure a fraction of host RAM with `memory_limit`
- Vector size
- typically about 2,048 values per vector batch
- Concurrency
- single-node CPU and I/O are shared by all attached readers/writers
Common mistakes & follow-ups
Common interview mistakes
- It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
- Reporting success from a job exit code without checking Memory bound and Vector size.
- Treating this example as complete without replay, rollback, or access boundaries:
duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);"performs a single-node ELT.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: An embedded OLAP engine process that stores and executes analytical SQL close to the application.
- What does the recovery plan do when this occurs? It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
- When is DuckDB insufficient for Vector size, and what does adding SQL on Files cost in Memory bound?
memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Querying Local Files at Lightning Speed with DuckDB with data engineer interview Q&A and hands-on practice.