Skip to content

Incremental probing for IndexJoin and IndexHashJoin to reduce memory usage #63303

@gengliqi

Description

@gengliqi

Enhancement

for {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
err := exec.Next(ctx, innerExec, iw.executorChk)
failpoint.Inject("ConsumeRandomPanic", nil)
if err != nil {
return err
}
if iw.executorChk.NumRows() == 0 {
break
}
innerResult.Add(iw.executorChk)
iw.executorChk = exec.TryNewCacheChunk(innerExec)
}
task.innerResult = innerResult

In the current probing process of IndexJoin and IndexHashJoin, all matched inner rows for the join keys of an outer chunk are fetched at once. This can lead to excessive memory usage and potentially cause the query to exceed the memory limit.

To address this, the probing process should fetch and consume inner rows incrementally, in a streaming fashion similar to hash join.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-8.5This bug affects the 8.5.x(LTS) versions.sig/executionSIG executiontype/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions