Dynamic hash join order switching
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### Is your feature request related to a problem or challenge?
Currently we only consider hash join order during planning time.
As this relies on rough estimates/heuristics, it can be the case the order is suboptimal and the order can be adjusted during exectution by looking at the actual size of the (build-side) data.
I added some log to the execution: for TPC-H query 7 and 21 can be adjusted when running with in-memory data, and query 4 when running on Parquet data (both for SF=1 and SF=10).
### Describe the solution you'd like
Based on the left side (partition or all) we can swap the join order if the size is smaller than the probe side (before building the build side.
The changed execution should look as follows:
* Detect the left side is smaller based on actual (left/build) size + estimated (right/probe) side
* Check if both sides will still fit in memory (lower than collect_left_threshold)
* Convert (left) side to in-memory stream
* Load right side into memory (we can recheck if this side is *really* smaller)
* Produce batches normally
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by tracing the hash-join planning and execution path described in the issue, using the execution logs for TPC-H queries 7, 21, and 4 as behavioral cases. Verify the stated size checks, in-memory conversion, and normal batch production; done means join order can switch during execution without exceeding collect_left_threshold.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100