From 02442aa5241b58b0add7fa38d2b141f2033d68ff Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Tue, 23 Aug 2022 14:30:45 +0800 Subject: [PATCH] executor: reduce a place of object allocation for HashAggExec --- executor/aggregate.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/executor/aggregate.go b/executor/aggregate.go index d33f5c8fcee5e..390f84e60acd3 100644 --- a/executor/aggregate.go +++ b/executor/aggregate.go @@ -1027,6 +1027,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) { @@ -1039,7 +1040,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 }