DUQL joined sub-queries: a top-level in stays a scan filter, the others lower to spilling joins
DecisionVerified 30 Sep 2026Holds project: dftracer-utils
Decision. The context, the choice, why, and the options that were turned down.
Context#
DUQL sub-queries with in, not in or an equality correlation need to handle sides larger than memory. The export (View::sink_json), pruning and scan stats must keep working. Decided with the user.
Decision#
- A top-level
k in (...)stays a scan filter over the side's distinct rows. The rows are bounded by the View memory budget and cached under a salted lookup-cache key. - Other
inandnot inlower to a Lookup join with a constant marker. - An equality-correlated scalar lowers to a Nest join that counts matches. Several rows give an error. No rows give the empty side default.
- A Semi join is used only for a
wherestage that is exactly anin, with whole-field keys of one exact non-JSON type. A typed join refuses mixed types. - The type probe of a joined side reads the first 65,536 rows instead of collecting under caps.
- Engine joins spill.
Why#
The scan filter keeps sink_json export, pruning and scan stats working.
Rejected options#
All in as spilling semi joins: the export writes the raw lines and cannot follow a join.
Also found by searching
- duql sub-query with in (...) larger than memory, does it become a join or a filter
- my duql not in sub-query side does not fit in memory, how is it executed
- how are duql in, not in and correlated scalar sub-queries lowered
- top-level k in (...) scan filter cached salted lookup key, Lookup join marker, Nest join counts matches
- duql subquery with k in (...) too large for memory, how are joins lowered
- not in subquery or equality-correlated scalar in duql, nest join counts matches error on several rows
- how does View::sink_json export work with duql sub-queries and spilling joins
- Lookup join constant marker for in and not in, salted lookup-cache key