From 20a5fb755489d9f48848014f3ec88379adb66cfc Mon Sep 17 00:00:00 2001 From: Marcus Gartner Date: Wed, 15 Mar 2023 21:39:12 +0000 Subject: [PATCH] tree: fix tuple encoding performance regression This commit fixes a performance regression in pgwire encoding of tuples introduced in #95009. Informs #98306 Epic: None Release note: None --- pkg/sql/sem/tree/pgwire_encode.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/sql/sem/tree/pgwire_encode.go b/pkg/sql/sem/tree/pgwire_encode.go index bc8529b802d1..77352de6f585 100644 --- a/pkg/sql/sem/tree/pgwire_encode.go +++ b/pkg/sql/sem/tree/pgwire_encode.go @@ -44,11 +44,14 @@ func (d *DTuple) pgwireFormat(ctx *FmtCtx) { // string printer called pgwireFormatStringInTuple(). ctx.WriteByte('(') comma := "" + tc := d.ResolvedType().TupleContents() for i, v := range d.D { ctx.WriteString(comma) - t := v.ResolvedType() - if tc := d.ResolvedType().TupleContents(); i < len(tc) { + var t *types.T + if i < len(tc) { t = tc[i] + } else { + t = v.ResolvedType() } switch dv := UnwrapDatum(nil, v).(type) { case dNull: