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. Determinism first, speed second.
The numbers, 1M rows, same queries and data on both engines:
Top-k: 88.81 ms down to 39.11. GROUP BY region: 92.14 down to 39.99. Global aggregate: 43.81 down to 20.42. Four scan threads takes the score from 3 of 8 to 5 of 8 against DuckDB single-threaded.
What did not move: the queries that are not scan-bound. If a query spends its time in a hash join or a sort, more scan threads just get the data to the slow part faster. That sounds obvious written down. It was less obvious before I measured it, because my first guess was that threads would help everything a bit. They do not.
One thing the change caught: an offset applied twice on nonzero-slice value arrays in aggregates. It only showed up once row groups were being decoded in parallel, because the single-threaded path never hit that slice shape. The fix went in with the same change. Parallelism finds bugs that serial code hides, which is a reason to test against a reference engine instead of trusting your own output.
The flag is opt-in and the default is still one thread. The GPU path stays opt-in too, for the same reason: at 1M rows the transfer costs about what the faster math saves.
Next is EXPLAIN ANALYZE. I want to see where time actually goes per operator instead of guessing from the total.