Menu

1 / 2

I threaded the scan in my query engine. The win was real but uneven.

DEV Community: cpp·Abiral pokhrel·about 8 hours ago
#w7g4A1ZF
#devtocpp#devto#dev#scan#query
Long article (402 words) — no AI summary yet.
Reading 0:00
15s threshold

I added threads to my query engine last week. One flag, --threads 4 , and the scan-bound queries got 1.8 to 2.9x faster. The rest barely moved. That split is the whole story.

The engine is qe, a C++20 columnar engine that reads Parquet through Arrow. A query is a scan plus some operators: filter, aggregate, sort, limit. Single-threaded it wins 3 of 8 benchmark queries against DuckDB and loses 5. The scan was the obvious place to start because that is where the time goes: reading and decompressing Parquet, not the arithmetic after it.

How it works now: each worker thread gets its own Parquet reader and decodes its own row groups. The trick is the output order. Batches still come out in exact serial order, so a query returns the same rows whether you run it with one thread or four. If results depended on the thread count, every test would be a coin flip, and I have 208 of them checked against DuckDB.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.