From 4b77cbc7aec191f7cf92221eb01ccd1c33aaf84a Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 3 Jan 2024 17:05:44 +0800 Subject: [PATCH] executor: avoid initializing chunk with max chunk size in some places --- pkg/executor/index_lookup_hash_join.go | 2 +- pkg/executor/index_lookup_join.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/executor/index_lookup_hash_join.go b/pkg/executor/index_lookup_hash_join.go index 47af647f06050..e2c1e84d6dd95 100644 --- a/pkg/executor/index_lookup_hash_join.go +++ b/pkg/executor/index_lookup_hash_join.go @@ -445,7 +445,7 @@ func (e *IndexNestedLoopHashJoin) newInnerWorker(taskCh chan *indexHashJoinTask, innerCtx: e.innerCtx, outerCtx: e.outerCtx, ctx: e.Ctx(), - executorChk: e.AllocPool.Alloc(e.innerCtx.rowTypes, e.MaxChunkSize(), e.MaxChunkSize()), + executorChk: e.AllocPool.Alloc(e.innerCtx.rowTypes, e.InitCap(), e.MaxChunkSize()), indexRanges: copiedRanges, keyOff2IdxOff: e.keyOff2IdxOff, stats: innerStats, diff --git a/pkg/executor/index_lookup_join.go b/pkg/executor/index_lookup_join.go index 8b1186941089e..e83fbb2f69b58 100644 --- a/pkg/executor/index_lookup_join.go +++ b/pkg/executor/index_lookup_join.go @@ -227,7 +227,7 @@ func (e *IndexLookUpJoin) newInnerWorker(taskCh chan *lookUpJoinTask) *innerWork outerCtx: e.outerCtx, taskCh: taskCh, ctx: e.Ctx(), - executorChk: e.AllocPool.Alloc(e.innerCtx.rowTypes, e.MaxChunkSize(), e.MaxChunkSize()), + executorChk: e.AllocPool.Alloc(e.innerCtx.rowTypes, e.InitCap(), e.MaxChunkSize()), indexRanges: copiedRanges, keyOff2IdxOff: e.keyOff2IdxOff, stats: innerStats, @@ -437,7 +437,7 @@ func (ow *outerWorker) buildTask(ctx context.Context) (*lookUpJoinTask, error) { } maxChunkSize := ow.ctx.GetSessionVars().MaxChunkSize for requiredRows > task.outerResult.Len() { - chk := ow.executor.NewChunkWithCapacity(ow.outerCtx.rowTypes, maxChunkSize, maxChunkSize) + chk := ow.executor.NewChunkWithCapacity(ow.outerCtx.rowTypes, requiredRows, maxChunkSize) chk = chk.SetRequiredRows(requiredRows, maxChunkSize) err := exec.Next(ctx, ow.executor, chk) if err != nil {