Ray's Knowledge Base
Unlock

Spill oversized joins using the existing duql value-key hash

DecisionVerified 30 Sep 2026Holds project: dftracer-utils
Decision. The context, the choice, why, and the options that were turned down.

Context#

A join's right side can exceed the plan memory budget while its full size is still unknown during streaming.

Decision#

Use a grace hash join in JoinCursor once the right side exceeds the budget. Partition by the hash of append_cell_key so typed and by-value joins place equal keys together. Start with 32 partitions and split oversized partitions by size up to four levels. Cross joins stay in memory. Spilled output is ordered by partition, not by input.

Why#

Using the existing value key preserves join equality semantics. The initial partition count handles unknown streamed size. Inbox 8a10897e8b records these choices; transcript 8397caa9dd reports reference tests and final-tree verification.

Rejected options#

Sort-merge would introduce a second set of key semantics.

Also found by searching

  • join right side exceeds plan memory budget, out of memory in JoinCursor
  • large join in duql runs out of memory when right table is too big
  • how do I spill a hash join to disk when build side size is unknown during streaming
  • grace hash join partition count recursive split, append_cell_key hash
  • join build side right table exceeds memory budget in streaming duql, what to do
  • how do I spill a hash join to disk when the right side size is unknown?
  • out of memory on large join in query engine, grace hash join partitions
  • JoinCursor spill partition by hash of key, sort-merge alternative rejected, cross join in memory