diff --git a/executor/benchmark_test.go b/executor/benchmark_test.go index 5bff882e426f6..7a05282ebc9ed 100644 --- a/executor/benchmark_test.go +++ b/executor/benchmark_test.go @@ -1130,6 +1130,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/executor/hash_table.go b/executor/hash_table.go index 4afdef58e1973..1562b37e8014c 100644 --- a/executor/hash_table.go +++ b/executor/hash_table.go @@ -243,11 +243,10 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk // Some variables used for memTracker. var ( matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize - lastChunkBufPointer *chunk.Chunk = nil + lastChunkBufPointer *chunk.Chunk = c.chkBuf memDelta int64 = 0 needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoinMask ) - c.chkBuf = nil c.memTracker.Consume(-c.chkBufSizeForOneProbe) if needTrackMemUsage { c.memTracker.Consume(int64(cap(innerPtrs)) * rowPtrSize) @@ -265,7 +264,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