diff --git a/pkg/executor/benchmark_test.go b/pkg/executor/benchmark_test.go index 54b7b5f71027d..458ca9250c0f2 100644 --- a/pkg/executor/benchmark_test.go +++ b/pkg/executor/benchmark_test.go @@ -1132,6 +1132,16 @@ func BenchmarkHashJoinExec(b *testing.B) { b.Run(fmt.Sprintf("%v", cas), func(b *testing.B) { benchmarkHashJoinExecWithCase(b, cas) }) + + cols = []*types.FieldType{ + types.NewFieldType(mysql.TypeLonglong), + } + cas = defaultHashJoinTestCase(cols, 0, false) + cas.keyIdx = []int{0} + cas.disk = true + b.Run(fmt.Sprintf("%v", cas), func(b *testing.B) { + benchmarkHashJoinExecWithCase(b, cas) + }) } func BenchmarkOuterHashJoinExec(b *testing.B) { diff --git a/pkg/executor/hash_table.go b/pkg/executor/hash_table.go index fa1dff03935f7..dbc9744c93e91 100644 --- a/pkg/executor/hash_table.go +++ b/pkg/executor/hash_table.go @@ -289,10 +289,9 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk var ( matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoinMask - lastChunkBufPointer *chunk.Chunk + lastChunkBufPointer = c.chkBuf memDelta int64 ) - c.chkBuf = nil c.memTracker.Consume(-c.chkBufSizeForOneProbe) if needTrackMemUsage { c.memTracker.Consume(int64(cap(innerPtrs)) * rowPtrSize) @@ -310,7 +309,7 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk if err != nil { return nil, nil, err } - if needTrackMemUsage && c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil { + if c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil { lastChunkSize := lastChunkBufPointer.MemoryUsage() c.chkBufSizeForOneProbe += lastChunkSize memDelta += lastChunkSize