From 9c60862af9ea54a6278ccf14306aed907edfc129 Mon Sep 17 00:00:00 2001 From: James Cor Date: Thu, 6 Nov 2025 11:39:16 -0800 Subject: [PATCH] don't make string unless in debug --- server/handler.go | 5 ++++- sql/analyzer/costed_index_scan.go | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/handler.go b/server/handler.go index 0cdcea2f57..392181fc02 100644 --- a/server/handler.go +++ b/server/handler.go @@ -702,7 +702,10 @@ func (h *Handler) resultForDefaultIter(ctx *sql.Context, c *mysql.Conn, schema s defer wg.Done() for { if r == nil { - r = &sqltypes.Result{Fields: resultFields} + r = &sqltypes.Result{ + Fields: resultFields, + Rows: make([][]sqltypes.Value, 0, rowsBatch), + } } if r.RowsAffected == rowsBatch { if err := resetCallback(r, more); err != nil { diff --git a/sql/analyzer/costed_index_scan.go b/sql/analyzer/costed_index_scan.go index 68be635157..62386ff036 100644 --- a/sql/analyzer/costed_index_scan.go +++ b/sql/analyzer/costed_index_scan.go @@ -141,9 +141,11 @@ func costedIndexLookup(ctx *sql.Context, n sql.Node, a *Analyzer, iat sql.IndexA ret = plan.NewTableAlias(aliasName, ret) } - a.Log("new indexed table: %s/%s/%s", ita.Index().Database(), ita.Index().Table(), ita.Index().ID()) - a.Log("index stats cnt: %d", stats.RowCount()) - a.Log("index stats histogram: %s", stats.Histogram().DebugString()) + if a.Debug { + a.Log("new indexed table: %s/%s/%s", ita.Index().Database(), ita.Index().Table(), ita.Index().ID()) + a.Log("index stats cnt: %d", stats.RowCount()) + a.Log("index stats histogram: %s", stats.Histogram().DebugString()) + } // excluded from tree + not included in index scan => filter above scan if len(filters) > 0 {