From 75c70ecd0aebc5c4a0675170458652a22459c609 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 24 Aug 2022 13:06:20 +0800 Subject: [PATCH] executor: reduce a place of object allocation for HashAggExec (#37300) close pingcap/tidb#37299 --- executor/aggregate.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/executor/aggregate.go b/executor/aggregate.go index 1fa60eb07630e..f492c0c49e7bd 100644 --- a/executor/aggregate.go +++ b/executor/aggregate.go @@ -1025,6 +1025,7 @@ func (e *HashAggExec) execute(ctx context.Context) (err error) { allMemDelta := int64(0) sel := make([]int, 0, e.childResult.NumRows()) + var tmpBuf [1]chunk.Row for j := 0; j < e.childResult.NumRows(); j++ { groupKey := string(e.groupKeyBuffer[j]) // do memory copy here, because e.groupKeyBuffer may be reused. if !e.groupSet.Exist(groupKey) { @@ -1037,7 +1038,8 @@ func (e *HashAggExec) execute(ctx context.Context) (err error) { } partialResults := e.getPartialResults(groupKey) for i, af := range e.PartialAggFuncs { - memDelta, err := af.UpdatePartialResult(e.ctx, []chunk.Row{e.childResult.GetRow(j)}, partialResults[i]) + tmpBuf[0] = e.childResult.GetRow(j) + memDelta, err := af.UpdatePartialResult(e.ctx, tmpBuf[:], partialResults[i]) if err != nil { return err }