cockroachdb / cockroachdb/cockroach
colexecjoin: optimize merge join when right cols are key
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Currently, whenever we're evaluating the vectorized merge join, we always copy at least one row from each batch from the right side in the "buffered group" spilling queue. This is needed in order to determine the length of the right group so that we know how many times we need to repeat each matching row from the left. However, when we have `right cols are key` property, we know that each right group will be exactly of length 1, so we could skip this redundant copy into the spilling queue.
An example setup where this case comes up is the following query on TPCH dataset:
```sql
EXPLAIN ANALYZE SELECT * FROM lineitem INNER MERGE JOIN orders ON l_orderkey = o_orderkey;
```
Jira issue: CRDB-35840
Contributor guide
Assessment
This issue has not been assessed yet.