From 70ed6e0a74280801d383694209d7a57cd3ca4713 Mon Sep 17 00:00:00 2001 From: Alfonso Subiotto Marques Date: Mon, 2 Nov 2020 16:24:33 +0100 Subject: [PATCH 1/3] sql: add TraceAnalyzer This commit adds TraceAnalyzer, which calculates general stats from a physical plan and an accompanying statement trace. This commit adds an example calculation of the number of netowrk bytes sent by each node in the plan. Additionally, this commit fixes non-determinism in outbox network statistics caused by variable metadata in order to make testing more useful. Release note: None --- pkg/sql/colexec/stats.go | 3 +- pkg/sql/conn_executor_exec.go | 11 +- pkg/sql/distsql_physical_planner.go | 38 +++- pkg/sql/distsql_running.go | 38 ++-- pkg/sql/exec_util.go | 8 + pkg/sql/execinfrapb/api.go | 3 + pkg/sql/execstats/BUILD.bazel | 45 +++++ pkg/sql/execstats/main_test.go | 29 +++ pkg/sql/execstats/traceanalyzer.go | 158 ++++++++++++++++ pkg/sql/execstats/traceanalyzer_test.go | 177 ++++++++++++++++++ pkg/sql/explain_distsql.go | 8 +- pkg/sql/flowinfra/outbox.go | 12 +- .../testdata/logic_test/dist_vectorize | 4 +- .../testdata/logic_test/explain_analyze_plans | 8 +- .../testdata/logic_test/vectorize_local | 6 +- .../exec/execbuilder/testdata/distsql_misc | 2 +- 16 files changed, 503 insertions(+), 47 deletions(-) create mode 100644 pkg/sql/execstats/BUILD.bazel create mode 100644 pkg/sql/execstats/main_test.go create mode 100644 pkg/sql/execstats/traceanalyzer.go create mode 100644 pkg/sql/execstats/traceanalyzer_test.go diff --git a/pkg/sql/colexec/stats.go b/pkg/sql/colexec/stats.go index d2d50af719b1..2c1131f19602 100644 --- a/pkg/sql/colexec/stats.go +++ b/pkg/sql/colexec/stats.go @@ -162,7 +162,8 @@ func (vsc *VectorizedStatsCollector) OutputStats( vsc.MaxAllocatedMem = 0 vsc.MaxAllocatedDisk = 0 vsc.NumBatches = 0 - vsc.BytesRead = 0 + // BytesRead is overridden to a useful value for tests. + vsc.BytesRead = 8 * vsc.NumTuples } span.SetSpanStats(&vsc.VectorizedStats) span.Finish() diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go index 8046a257df66..c9adbcff9865 100644 --- a/pkg/sql/conn_executor_exec.go +++ b/pkg/sql/conn_executor_exec.go @@ -962,9 +962,16 @@ func (ex *connExecutor) execWithDistSQLEngine( evalCtx := planner.ExtendedEvalContext() planCtx := ex.server.cfg.DistSQLPlanner.NewPlanningCtx(ctx, evalCtx, planner, planner.txn, distribute) planCtx.stmtType = recv.stmtType - if planner.collectBundle { - planCtx.saveDiagram = func(diagram execinfrapb.FlowDiagram) { + if ex.server.cfg.TestingKnobs.TestingSaveFlows != nil { + planCtx.saveFlows = ex.server.cfg.TestingKnobs.TestingSaveFlows(planner.stmt.SQL) + } else if planner.collectBundle { + planCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + diagram, err := planCtx.flowSpecsToDiagram(ctx, flows) + if err != nil { + return err + } planner.curPlan.distSQLDiagrams = append(planner.curPlan.distSQLDiagrams, diagram) + return nil } } diff --git a/pkg/sql/distsql_physical_planner.go b/pkg/sql/distsql_physical_planner.go index 33a3b3d13852..966f5ab0a55a 100644 --- a/pkg/sql/distsql_physical_planner.go +++ b/pkg/sql/distsql_physical_planner.go @@ -605,11 +605,10 @@ type PlanningCtx struct { // be replaced by evaluation. Should only be set by EXPLAIN. noEvalSubqueries bool - // If set, a diagram for the plan will be generated and passed to this - // function. - saveDiagram func(execinfrapb.FlowDiagram) - // If set, the diagram passed to saveDiagram will show the types of each - // stream. + // If set, the flows for the physical plan will be passed to this function. + // The flows are not safe for use past the lifetime of the saveFlows function. + saveFlows func(map[roachpb.NodeID]*execinfrapb.FlowSpec) error + // If set, the result of flowSpecsToDiagram will show the types of each stream. saveDiagramShowInputTypes bool } @@ -637,6 +636,35 @@ func (p *PlanningCtx) EvaluateSubqueries() bool { return !p.noEvalSubqueries } +// flowSpecsToDiagram is a helper function used to convert flowSpecs into a +// FlowDiagram using this PlanningCtx's information. +func (p *PlanningCtx) flowSpecsToDiagram( + ctx context.Context, flows map[roachpb.NodeID]*execinfrapb.FlowSpec, +) (execinfrapb.FlowDiagram, error) { + // Local flows might not have the UUID field set. We need it to be set to + // distinguish statistics for processors in subqueries vs the main query vs + // postqueries. + if len(flows) == 1 { + for _, f := range flows { + if f.FlowID == (execinfrapb.FlowID{}) { + f.FlowID.UUID = uuid.MakeV4() + } + } + } + log.VEvent(ctx, 1, "creating plan diagram") + var stmtStr string + if p.planner != nil && p.planner.stmt != nil { + stmtStr = p.planner.stmt.String() + } + diagram, err := execinfrapb.GeneratePlanDiagram( + stmtStr, flows, p.saveDiagramShowInputTypes, + ) + if err != nil { + return nil, err + } + return diagram, nil +} + // PhysicalPlan is a partial physical plan which corresponds to a planNode // (partial in that it can correspond to a planNode subtree and not necessarily // to the entire planNode for a given query). diff --git a/pkg/sql/distsql_running.go b/pkg/sql/distsql_running.go index 6cc0c83c27ea..de2fb2c8b8ab 100644 --- a/pkg/sql/distsql_running.go +++ b/pkg/sql/distsql_running.go @@ -45,7 +45,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/mon" "github.com/cockroachdb/cockroach/pkg/util/tracing" - "github.com/cockroachdb/cockroach/pkg/util/uuid" "github.com/cockroachdb/errors" ) @@ -338,30 +337,11 @@ func (dsp *DistSQLPlanner) Run( return func() {} } - if planCtx.saveDiagram != nil { - // Local flows might not have the UUID field set. We need it to be set to - // distinguish statistics for processors in subqueries vs the main query vs - // postqueries. - if len(flows) == 1 { - for _, f := range flows { - if f.FlowID == (execinfrapb.FlowID{}) { - f.FlowID.UUID = uuid.MakeV4() - } - } - } - log.VEvent(ctx, 1, "creating plan diagram") - var stmtStr string - if planCtx.planner != nil && planCtx.planner.stmt != nil { - stmtStr = planCtx.planner.stmt.String() - } - diagram, err := execinfrapb.GeneratePlanDiagram( - stmtStr, flows, planCtx.saveDiagramShowInputTypes, - ) - if err != nil { + if planCtx.saveFlows != nil { + if err := planCtx.saveFlows(flows); err != nil { recv.SetError(err) return func() {} } - planCtx.saveDiagram(diagram) } if logPlanDiagram { @@ -872,8 +852,13 @@ func (dsp *DistSQLPlanner) planAndRunSubquery( subqueryPlanCtx := dsp.NewPlanningCtx(ctx, evalCtx, planner, planner.txn, distributeSubquery) subqueryPlanCtx.stmtType = tree.Rows if planner.collectBundle { - subqueryPlanCtx.saveDiagram = func(diagram execinfrapb.FlowDiagram) { + subqueryPlanCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + diagram, err := subqueryPlanCtx.flowSpecsToDiagram(ctx, flows) + if err != nil { + return err + } planner.curPlan.distSQLDiagrams = append(planner.curPlan.distSQLDiagrams, diagram) + return nil } } // Don't close the top-level plan from subqueries - someone else will handle @@ -1165,8 +1150,13 @@ func (dsp *DistSQLPlanner) planAndRunPostquery( postqueryPlanCtx.stmtType = tree.Rows postqueryPlanCtx.ignoreClose = true if planner.collectBundle { - postqueryPlanCtx.saveDiagram = func(diagram execinfrapb.FlowDiagram) { + postqueryPlanCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + diagram, err := postqueryPlanCtx.flowSpecsToDiagram(ctx, flows) + if err != nil { + return err + } planner.curPlan.distSQLDiagrams = append(planner.curPlan.distSQLDiagrams, diagram) + return nil } } diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go index f5026b69dfaa..3680f72dc02c 100644 --- a/pkg/sql/exec_util.go +++ b/pkg/sql/exec_util.go @@ -47,6 +47,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/colexec" "github.com/cockroachdb/cockroach/pkg/sql/distsql" "github.com/cockroachdb/cockroach/pkg/sql/execinfra" + "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" "github.com/cockroachdb/cockroach/pkg/sql/gcjob/gcjobnotifier" "github.com/cockroachdb/cockroach/pkg/sql/opt" "github.com/cockroachdb/cockroach/pkg/sql/parser" @@ -853,6 +854,13 @@ type ExecutorTestingKnobs struct { // should be performed (typically turned on during tests only to guard against // wild descriptors which are corrupted due to bugs). TestingDescriptorValidation bool + + // TestingSaveFlows, if set, will be called with the given stmt. The resulting + // function will be called with the physical plan of that statement's main + // query (i.e. no subqueries). The physical plan is only safe for use for the + // lifetime of this function. Note that returning a nil function is + // unsupported and will lead to a panic. + TestingSaveFlows func(stmt string) func(map[roachpb.NodeID]*execinfrapb.FlowSpec) error } // PGWireTestingKnobs contains knobs for the pgwire module. diff --git a/pkg/sql/execinfrapb/api.go b/pkg/sql/execinfrapb/api.go index 50bffec44f5f..6e8b3ebff178 100644 --- a/pkg/sql/execinfrapb/api.go +++ b/pkg/sql/execinfrapb/api.go @@ -17,6 +17,9 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/uuid" ) +// ProcessorID identifies a processor in the context of a specific flow. +type ProcessorID int + // StreamID identifies a stream; it may be local to a flow or it may cross // machine boundaries. The identifier can only be used in the context of a // specific flow. diff --git a/pkg/sql/execstats/BUILD.bazel b/pkg/sql/execstats/BUILD.bazel new file mode 100644 index 000000000000..c86c75ba6caf --- /dev/null +++ b/pkg/sql/execstats/BUILD.bazel @@ -0,0 +1,45 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "execstats", + srcs = ["traceanalyzer.go"], + importpath = "github.com/cockroachdb/cockroach/pkg/sql/execstats", + visibility = ["//visibility:public"], + deps = [ + "//pkg/roachpb", + "//pkg/sql/colexec/execpb", + "//pkg/sql/execinfrapb", + "//pkg/sql/flowinfra", + "//pkg/util/tracing/tracingpb", + "//vendor/github.com/cockroachdb/errors", + "//vendor/github.com/gogo/protobuf/types", + ], +) + +go_test( + name = "execstats_test", + srcs = [ + "main_test.go", + "traceanalyzer_test.go", + ], + deps = [ + ":execstats", + "//pkg/base", + "//pkg/roachpb", + "//pkg/security", + "//pkg/security/securitytest", + "//pkg/server", + "//pkg/sql", + "//pkg/sql/execinfra", + "//pkg/sql/execinfrapb", + "//pkg/sql/sessiondata", + "//pkg/sql/sessiondatapb", + "//pkg/testutils/serverutils", + "//pkg/testutils/sqlutils", + "//pkg/testutils/testcluster", + "//pkg/util/leaktest", + "//pkg/util/log", + "//pkg/util/tracing", + "//vendor/github.com/stretchr/testify/require", + ], +) diff --git a/pkg/sql/execstats/main_test.go b/pkg/sql/execstats/main_test.go new file mode 100644 index 000000000000..0e206608e45f --- /dev/null +++ b/pkg/sql/execstats/main_test.go @@ -0,0 +1,29 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package execstats_test + +import ( + "os" + "testing" + + "github.com/cockroachdb/cockroach/pkg/security" + "github.com/cockroachdb/cockroach/pkg/security/securitytest" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" +) + +func TestMain(m *testing.M) { + security.SetAssetLoader(securitytest.EmbeddedAssets) + serverutils.InitTestServerFactory(server.TestServerFactory) + serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + os.Exit(m.Run()) +} diff --git a/pkg/sql/execstats/traceanalyzer.go b/pkg/sql/execstats/traceanalyzer.go new file mode 100644 index 000000000000..42481fccb632 --- /dev/null +++ b/pkg/sql/execstats/traceanalyzer.go @@ -0,0 +1,158 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package execstats + +import ( + "strconv" + + "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/sql/colexec/execpb" + "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" + "github.com/cockroachdb/cockroach/pkg/sql/flowinfra" + "github.com/cockroachdb/cockroach/pkg/util/tracing/tracingpb" + "github.com/cockroachdb/errors" + "github.com/gogo/protobuf/types" +) + +type processorStats struct { + nodeID roachpb.NodeID + stats execinfrapb.DistSQLSpanStats +} + +type streamStats struct { + originNodeID roachpb.NodeID + destinationNodeID roachpb.NodeID + stats execinfrapb.DistSQLSpanStats +} + +// TraceAnalyzer is a struct that helps calculate top-level statistics from a +// collection of flows and an accompanying trace of the flows' execution. +// Example usage: +// analyzer := NewTraceAnalyzer(flows) +// analyzer.AddTrace(trace) +// bytesGroupedByNode, err := analyzer.GetNetworkBytesSent() +type TraceAnalyzer struct { + // processorIDMap maps a processor ID to stats associated with this processor + // extracted from a trace as well as some metadata. Note that it is possible + // for the processorStats to have nil stats, which indicates that no stats + // were found for the given processor in the trace. + processorStats map[execinfrapb.ProcessorID]*processorStats + // streamIDMap maps a stream ID to stats associated with this stream extracted + // from a trace as well as some metadata. Note that is is possible for the + // streamStats to have nil stats, which indicates that no stats were found + // for the given stream in the trace. + streamStats map[execinfrapb.StreamID]*streamStats +} + +// NewTraceAnalyzer creates a TraceAnalyzer with the corresponding physical +// plan. Call AddTrace to calculate meaningful stats. +func NewTraceAnalyzer(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) *TraceAnalyzer { + a := &TraceAnalyzer{ + processorStats: make(map[execinfrapb.ProcessorID]*processorStats), + streamStats: make(map[execinfrapb.StreamID]*streamStats), + } + + // Annotate the maps with physical plan information. + for nodeID, flow := range flows { + for _, proc := range flow.Processors { + a.processorStats[execinfrapb.ProcessorID(proc.ProcessorID)] = &processorStats{nodeID: nodeID} + for _, output := range proc.Output { + for _, stream := range output.Streams { + if stream.Type == execinfrapb.StreamEndpointSpec_REMOTE { + a.streamStats[stream.StreamID] = &streamStats{ + originNodeID: nodeID, + destinationNodeID: stream.TargetNodeID, + } + } + } + } + } + } + + return a +} + +// AddTrace adds the stats from the given trace to the TraceAnalyzer. +func (a *TraceAnalyzer) AddTrace(trace []tracingpb.RecordedSpan) error { + // Annotate the maps with stats extracted from the trace. + for _, span := range trace { + if span.Stats == nil { + // No stats to unmarshal (e.g. noop processors at time of writing). + continue + } + + var da types.DynamicAny + if err := types.UnmarshalAny(span.Stats, &da); err != nil { + return errors.Wrap(err, "unable to unmarshal in TraceAnalyzer") + } + stats, ok := da.Message.(execinfrapb.DistSQLSpanStats) + if !ok { + continue + } + + // Get the processor or stream id for this span. If neither exists, this + // span doesn't belong to a processor or stream. + if pid, ok := span.Tags[execinfrapb.ProcessorIDTagKey]; ok { + stringID := pid + id, err := strconv.Atoi(stringID) + if err != nil { + return errors.Wrap(err, "unable to convert span processor ID tag in TraceAnalyzer") + } + processorStats := a.processorStats[execinfrapb.ProcessorID(id)] + if processorStats == nil { + return errors.Errorf("trace has span for processor %d but the processor does not exist in the physical plan", id) + } + processorStats.stats = stats + } else if sid, ok := span.Tags[execinfrapb.StreamIDTagKey]; ok { + stringID := sid + id, err := strconv.Atoi(stringID) + if err != nil { + return errors.Wrap(err, "unable to convert span processor ID tag in TraceAnalyzer") + } + streamStats := a.streamStats[execinfrapb.StreamID(id)] + if streamStats == nil { + return errors.Errorf("trace has span for stream %d but the stream does not exist in the physical plan", id) + } + streamStats.stats = stats + } + } + + return nil +} + +func getNetworkBytesFromDistSQLSpanStats(dss execinfrapb.DistSQLSpanStats) (int64, error) { + switch v := dss.(type) { + case *flowinfra.OutboxStats: + return v.BytesSent, nil + case *execpb.VectorizedStats: + // VectorizedStats are output by the Inbox, hence the read/sent difference + // with OutboxStats. + return v.BytesRead, nil + } + return 0, errors.Errorf("could not get network bytes from %T", dss) +} + +// GetNetworkBytesSent returns the number of bytes sent over the network the +// trace reports, grouped by NodeID. +func (a *TraceAnalyzer) GetNetworkBytesSent() (map[roachpb.NodeID]int64, error) { + result := make(map[roachpb.NodeID]int64) + for _, stats := range a.streamStats { + if stats.stats == nil { + continue + } + bytes, err := getNetworkBytesFromDistSQLSpanStats(stats.stats) + if err != nil { + return nil, err + } + result[stats.originNodeID] += bytes + } + return result, nil +} diff --git a/pkg/sql/execstats/traceanalyzer_test.go b/pkg/sql/execstats/traceanalyzer_test.go new file mode 100644 index 000000000000..7bbeed23e300 --- /dev/null +++ b/pkg/sql/execstats/traceanalyzer_test.go @@ -0,0 +1,177 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package execstats_test + +import ( + "context" + "fmt" + "testing" + + "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/roachpb" + "github.com/cockroachdb/cockroach/pkg/security" + "github.com/cockroachdb/cockroach/pkg/sql" + "github.com/cockroachdb/cockroach/pkg/sql/execinfra" + "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" + "github.com/cockroachdb/cockroach/pkg/sql/execstats" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/log" + "github.com/cockroachdb/cockroach/pkg/util/tracing" + "github.com/stretchr/testify/require" +) + +// TestTraceAnalyzer verifies that the TraceAnalyzer correctly calculates +// expected top-level statistics from a physical plan and an accompanying trace +// from that plan's execution. It does this by starting up a multi-node cluster, +// enabling tracing, capturing the physical plan of a test statement, and +// constructing a TraceAnalyzer from the resulting trace and physical plan. +func TestTraceAnalyzer(t *testing.T) { + defer log.Scope(t).Close(t) + defer leaktest.AfterTest(t)() + + const ( + testStmt = "SELECT * FROM test.foo" + numNodes = 3 + ) + + ctx := context.Background() + analyzerChan := make(chan *execstats.TraceAnalyzer, 1) + tc := serverutils.StartNewTestCluster(t, numNodes, base.TestClusterArgs{ + ReplicationMode: base.ReplicationManual, + ServerArgs: base.TestServerArgs{ + UseDatabase: "test", + Knobs: base.TestingKnobs{ + SQLExecutor: &sql.ExecutorTestingKnobs{ + TestingSaveFlows: func(stmt string) func(map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + if stmt != testStmt { + return func(map[roachpb.NodeID]*execinfrapb.FlowSpec) error { return nil } + } + return func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + analyzer := execstats.NewTraceAnalyzer(flows) + analyzerChan <- analyzer + return nil + } + }, + }, + DistSQL: &execinfra.TestingKnobs{ + // DeterministicStats are set to eliminate variability when + // calculating expected results. Note that this sets some fields to 0 + // (such as execution time), so a more dynamic approach might be + // needed for those kinds of tests. + DeterministicStats: true, + }, + }, + }}) + defer tc.Stopper().Stop(ctx) + + const gatewayNode = 0 + db := tc.ServerConn(gatewayNode) + sqlDB := sqlutils.MakeSQLRunner(db) + + sqlutils.CreateTable( + t, db, "foo", + "k INT PRIMARY KEY, v INT", + 30, + sqlutils.ToRowFn(sqlutils.RowIdxFn, sqlutils.RowModuloFn(2)), + ) + + sqlDB.Exec(t, "ALTER TABLE test.foo SPLIT AT VALUES (10), (20)") + sqlDB.Exec( + t, + fmt.Sprintf("ALTER TABLE test.foo EXPERIMENTAL_RELOCATE VALUES (ARRAY[%d], 0), (ARRAY[%d], 10), (ARRAY[%d], 20)", + tc.Server(0).GetFirstStoreID(), + tc.Server(1).GetFirstStoreID(), + tc.Server(2).GetFirstStoreID(), + ), + ) + + execCfg := tc.Server(gatewayNode).ExecutorConfig().(sql.ExecutorConfig) + + var ( + rowexecTraceAnalyzer *execstats.TraceAnalyzer + colexecTraceAnalyzer *execstats.TraceAnalyzer + ) + for _, vectorizeMode := range []sessiondatapb.VectorizeExecMode{sessiondatapb.VectorizeOff, sessiondatapb.VectorizeOn} { + var sp *tracing.Span + ctx, sp = tracing.StartSnowballTrace(ctx, execCfg.AmbientCtx.Tracer, t.Name()) + ie := execCfg.InternalExecutor + ie.SetSessionData( + &sessiondata.SessionData{ + SessionData: sessiondatapb.SessionData{ + VectorizeMode: vectorizeMode, + }, + LocalOnlySessionData: sessiondata.LocalOnlySessionData{ + DistSQLMode: sessiondata.DistSQLOn, + }, + }, + ) + _, err := ie.QueryEx( + ctx, + t.Name(), + nil, /* txn */ + sessiondata.InternalExecutorOverride{User: security.RootUserName()}, + testStmt, + ) + sp.Finish() + require.NoError(t, err) + trace := sp.GetRecording() + analyzer := <-analyzerChan + require.NoError(t, analyzer.AddTrace(trace)) + switch vectorizeMode { + case sessiondatapb.VectorizeOff: + rowexecTraceAnalyzer = analyzer + case sessiondatapb.VectorizeOn: + colexecTraceAnalyzer = analyzer + default: + t.Fatalf("programming error, vectorize mode %s not handled", vectorizeMode) + } + } + + t.Run("NetworkBytesSent", func(t *testing.T) { + for _, tc := range []struct { + analyzer *execstats.TraceAnalyzer + // expectedBytes are defined as a range in order to not have to change + // this test too often if the wire format changes. + expectedBytesRange [2]int64 + }{ + { + analyzer: rowexecTraceAnalyzer, + expectedBytesRange: [2]int64{32, 128}, + }, + { + analyzer: colexecTraceAnalyzer, + // Note that the expectedBytes in the colexec case is larger than the + // rowexec case because the DeterministicStats flag behaves differently + // in each case. In rowexec, the outbox row bytes are returned. In + // colexec, an artificial number proportional to the number of tuples is + // returned. + expectedBytesRange: [2]int64{128, 256}, + }, + } { + networkBytesGroupedByNode, err := tc.analyzer.GetNetworkBytesSent() + require.NoError(t, err) + require.Equal( + t, numNodes-1, len(networkBytesGroupedByNode), "expected all nodes minus the gateway node to have sent bytes", + ) + + var actualBytes int64 + for _, bytes := range networkBytesGroupedByNode { + actualBytes += bytes + } + require.GreaterOrEqual(t, actualBytes, tc.expectedBytesRange[0]) + require.LessOrEqual(t, actualBytes, tc.expectedBytesRange[1]) + } + }) +} diff --git a/pkg/sql/explain_distsql.go b/pkg/sql/explain_distsql.go index b924bcd4eddf..108f367c8c1c 100644 --- a/pkg/sql/explain_distsql.go +++ b/pkg/sql/explain_distsql.go @@ -14,6 +14,7 @@ import ( "context" "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" "github.com/cockroachdb/cockroach/pkg/sql/physicalplan" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" @@ -205,8 +206,13 @@ func (n *explainDistSQLNode) startExec(params runParams) error { ) defer recv.Release() - planCtx.saveDiagram = func(d execinfrapb.FlowDiagram) { + planCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + d, err := planCtx.flowSpecsToDiagram(ctx, flows) + if err != nil { + return err + } diagram = d + return nil } planCtx.saveDiagramShowInputTypes = n.options.Flags[tree.ExplainFlagTypes] diff --git a/pkg/sql/flowinfra/outbox.go b/pkg/sql/flowinfra/outbox.go index 7b6812ab6e24..c2e08d2ad5e8 100644 --- a/pkg/sql/flowinfra/outbox.go +++ b/pkg/sql/flowinfra/outbox.go @@ -153,7 +153,14 @@ func (m *Outbox) flush(ctx context.Context) error { } msg := m.encoder.FormMessage(ctx) if m.statsCollectionEnabled { - m.stats.BytesSent += int64(msg.Size()) + if m.flowCtx.Cfg.TestingKnobs.DeterministicStats { + // Some fields in the msg have variable sizes across different runs (e.g. + // metadata). To keep a useful bytes value for tests, we only count the + // encoded row message size. + m.stats.BytesSent += int64(len(msg.Data.RawBytes)) + } else { + m.stats.BytesSent += int64(msg.Size()) + } } if log.V(3) { @@ -282,9 +289,6 @@ func (m *Outbox) mainLoop(ctx context.Context) error { if err != nil { return err } - if m.flowCtx.Cfg.TestingKnobs.DeterministicStats { - m.stats.BytesSent = 0 - } span.SetSpanStats(&m.stats) span.Finish() spanFinished = true diff --git a/pkg/sql/logictest/testdata/logic_test/dist_vectorize b/pkg/sql/logictest/testdata/logic_test/dist_vectorize index 78edd85e7b0c..e2a6880cb96b 100644 --- a/pkg/sql/logictest/testdata/logic_test/dist_vectorize +++ b/pkg/sql/logictest/testdata/logic_test/dist_vectorize @@ -51,12 +51,12 @@ NULL /1 {5} 5 query T SELECT url FROM [EXPLAIN ANALYZE SELECT count(*) FROM kv] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzMld1um0AQhe_7FKu5squ1MD92HK5ipa6E5EBqHPUnQhGBkYuCWbq7pKksv3sFRAq2koVKjfAlu3OYcz4Pnh2IXynY4C-Wi8s1KXhKPq-8K3K7-Ha9nDsumbvz5fcfCzL45Phr_8tySJ5LI1ZkcvBxWNc_PAZAIWMxuuEWBdi3oAMFAyiYQMECChMIKOScRSgE42XJrhI48RPYYwpJlheyPA4oRIwj2DuQiUwRbFiH9ymuMIyRa2OgEKMMk7Rq8_B4kfNkG_I_QMHPw0zYZKSVjb1C2sRlGQKF-1BGP1EQVsi8PC5fIos8bRyVfh2PyGSLNhkLoMDZb0E4hnF5Gewp1KXPHoUMNwi2vqfdc8w3G46bUDKuTQ5jXHo37vpu5X31B8PufvEJo0ImLHux_ZZP402fL_aKjPEYOcYH3oK9Ool-9Iv4N1d3jrseXOjvk8Q8SKJ3nxy9fXI0Y6SZPc1OS5IG8Wmvs2N0J250IG6ONKsn4i1JGsTPeiVudidudiBujap_nz6ItyRpEJ_1StzqTtzqQHwy6ol3S44G7_OT2Uev-FyhyFkm8Ggvvf7mcbmvMN5gvdwEK3iE15xFVZv60at01UGMQta3ev3gZPVVabAp1pVi40CsH4sNdeeW1qZSbanF1r_4rihWQP_PjB5amSitTNU5pqeT40xpZabOMTudHOfqqRy3fBDqz-l9kwT7D38DAAD__55OIg4= +https://cockroachdb.github.io/distsqlplan/decode.html#eJzMlV1vm0wQhe_fX7GaK_vVWpgPOw5XcVNXQnIgNY76EaGIwMhFwSzdXdJElv97BaQqWM1CLxpxybCHOYdnYA4gvqdgg79ary63pOAp-bDxrsjt6vP1eum4ZOku11--rsjoveNv_Y_rMXk5GrEik6P_x_X5h8cAKGQsRjfcowD7FnSgYAAFEyhYQGEGAYWcswiFYLw8cqgETvwE9pRCkuWFLMsBhYhxBPsAMpEpgg3b8D7FDYYxcm0KFGKUYZJWbR4eL3Ke7EP-DBT8PMyETSZa2dgrpE1cliFQuA9l9A0FYYXMy3L5EFnkaaNU-nU8IpM92mQqStGzREE4hrFNFuQdUODsx6-CDsGRQi1-cS1kuEOw9SPtn2y523HchZJxbdYOdunduNu7jffJH437J8AnjAqZsEwV5DXnxqvOfxsuMsZj5Bi33AZHdTb9hJp_c3XnuNvRhf5W2cxWNr3_vOnd86YZE80czMR1ZGtQmQ9s4oz-VIweVMyJZg2GSke2BpWzgVEx-1Mxe1CxJtWfbhhUOrI1qCwGRsXqT8XqQWU2GQyTjmQNJucDY9Kx6zcocpYJPNmcf37ytNyoGO-wXr-CFTzCa86iqk196VW6qhCjkPVdvb5wsvpWabAp1pVioyXWT8WGunNHa1OpttRi6298V2-xeqH_ao7b5mZKc3N1svmQk50pzS3UyRZDTnaunuVpx2ek_gjfOltw_O9nAAAA__--x3E3 query T SELECT url FROM [EXPLAIN ANALYZE SELECT * FROM kv JOIN kw ON kv.k = kw.k] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzMWF1v4jgUfd9fYd2nmR0zwflghkgjUe2yEiMGuqUPu1vxkBIvRNAk6zilVdX_vgqZqoWCY2NM8lYSO-ec6-NT-z5B9t8KfJj0h_3frlHOVuiPq_EPdNP_63J4MRihi9HF8O9_-ujD74PJ9eTP4Uf0c-iv5cDlPfo-HozQco3GI7S8_7xE39By_Xk5BQxxEtJRcEcz8G-AAAYbMDiAwQUMHkwxpCyZ0SxLWDHkaTNhED6A38YQxWnOi8dTDLOEUfCfgEd8RcGH6-B2Ra9oEFJmtQFDSHkQrTYwy_teyqK7gD0ChkkaxJmPWlYBfBvw2YJmKMl5mnMfFRN5nq7ePCo4DsaIR3fUR-0MMLBknSFGg7B4OX3GUA4t6b7QuX1EiyBbbBPpFeOnGDIezCn45Bkfp6-zo2_9Xp9FmqDQPqjw9TsJCymj4e53PhXAUqP2FOsHZXP6PYliyiyy44YV_Zd_6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EcBVez_kFDyMuLBsoRFyG8XwBM7vrZyK-DcUDULjMwiQPSM8qga9DOZnynKSFzAoZkHKjLLL5q0tljYMRkfEtD4idl5seJM-J4GEUkGPyC1AQ6f3zBQbjJwrV5orAc4HXD2Qa5tPl0vrl-jGFXIY3HAL2RLdjfLTC-P4tY4t1k7OzkfPLc1IRccGj1ed8KIG1Vq1p31cubviXNE64sNiKYub8H_muzz68_yzim2n1J1AYlc3pM9p3aN-lfU-_m_wHnxQyThNVU5e7-NIhV6NDRbKO_Vriw7SXZhbzlylrEPF1iHi2gom3xITp65vVO9pyepbbQX2zbTl_0vB0Rzk7Gzm36Gl2OJ529FXhaDjB7VkNeOzJCQ04H2s4oaOcnY2cW3SCczhOcPVV4Wo4wetZfgdVwbblfKLhhI5ydjZybtEJ7uE4wdNXhafhBL_XQU2wbRn79T7oWYyESUQYSeWUiw6ydzayb9ER3uE4ouZ7-ILnWZrkfOULaP2T7bIxPLrhVbvztBAT_k2kkwVM9XO02Lc4v0Y8l9Vdp_oxSJ5v5TKUul9Q9vqGLN6lfglH2BJeK7wh9gkGext3NSmOoV8OojPMNwrOGqjSMaNKdQlH2BIQ9E8w2HhVqotj6JeD6MyKKncN7qyC26_B3WVHrG52lZvZsqBsM5r2zIa9snlqbHTK4-mjwh5J33CW14CjshwfKL7ZsFd2Ro2NTnkdVapLQIU9kr7hLK8BR2U5XpVHTcK-7eI-7THI1dhmj-tqbHSC69hVXQIuyE0Lw_Cp_XiPQa7GNntcV2OjE1xHleoScEGOV2VNdWZP7SddDnJmeP6i_pgyOHkx3hqzx_UacPx5XWsEsd8ZjOEhDAYclec7kKbBAQ22NfhDu5Y09zqIYY0mMa2r482oZ3eZbrw6s-f3GnDDma4GNzyDqUNHh7mWbZtMANuP1SYzwp1nSpPpYMvgpofqjeaDpv6jvBkH7TXTx08__RcAAP__bh716Q== # Verify execution. statement ok diff --git a/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans b/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans index 208d73594df1..3d26e5386512 100644 --- a/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans +++ b/pkg/sql/logictest/testdata/logic_test/explain_analyze_plans @@ -60,19 +60,19 @@ NULL /1 {5} 5 query T SELECT url FROM [EXPLAIN ANALYZE (DISTSQL) SELECT kv.k, avg(kw.k) FROM kv JOIN kw ON kv.k=kw.k GROUP BY kv.k] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzcWG1v4jgX_f78CsufWk2YYCdQijQSPLPdFSOadHmRtjtCVUq8gKAJ64R2RlX_-yrQUSEUXwfXSdpvQF7OPdeX4-PziKN_F7iJ-xfdi68DtOIL9HvPvUTfL_666rY7Dmo77e713xfo5LdOf9D_s3uKnm-d33-eG8i7n5zMHz7PTzePze_RN7fjoPkDcp31LegLSq6jP3ru8Ar9_3r94wgbOAh95nh3LMLN75hgA1NsYAsb2MYGruGRgZc8HLMoCnlyy-P6gY7_AzerBp4Fy1Wc_Dwy8DjkDDcfcTyLFww38cC7XbAe83zGzSo2sM9ib7ZYw8zvW0s-u_P4T2zg_tILoiaqmAmwu4qbqJWUcevF4ymLULiKl8mPySvi1XKx9VNyW8dF8eyONVE1wgbm4UOEOPP85OLoycCbWzeF_yrs9ieaetF0t6RWcv_IwFHsTRhukifjOKb1FNOHfaYmKRdXepDry3tC7jPO_PR7PiXAUne90rZLxifsWzgLGDdJakIW7J_4pEU-nX7hs8l08_GlZUaLyneN_WDjVTwLg5fm7XbrpRNWllVvTyacTbw45Cap7TXYwO6mGc9L3Haubxx3cOMMu92TFknI9IeXJy2afPrqDp3B8-e3YpVtBmy1GRC3h1bV2tMfXt50kgZZybceC3zG12OAWtRsWVpGoSbRkFXwWkte7YYTVsKlSVNzIlF2LVvZ9Z2yibxuEVihTVoxrRLpFjmW65mERpeMKz3INUeNJuXTaGDVtzW6_rE0OvMMABpN3rtGU3kBoBJiZ1VMu0QCQI7l2pAQu5JxpQe55ih2tHxiB6z6ttidfSyxyzwDgNjR9y52l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TAH95wXGsKHftQHFoO9YUWsK1ibLVssn1iAqrSO7rF4JpDCwCulzlZO4-KUkvpR6IiB9Z3b02Ro2rJ4OppROqsXuhIWjl1aN6lrJ1aS8wlALjmXYEYXD2SSGkTKEKpBe-gTUAdemMbWTsIr7g6ccXphKwdZUuMJwC45t0JhK48ELdLR0BZmhMKhK45ooh3I6YjismtCQBuej4b3ahA6KXslCB1aG6BydUJAG56Phtdq0DopSyWIHVoboF4f0KABQoxuUEBwHVHFKOrEgBdLYkoBCSjWxRa6S0K1bhF0V6d3jULAK45okDoRrmrZxOZIUQ1blHeQZsm1ywAuOaIAqEb5a6eTaS0Kd6iUGCLQk1uUQBwzREFQtc8jY0uSyB0QxskWq0tSv_pt_8DAAD__3l-CW8= # This query verifies stats collection for the hashJoiner, distinct and sorter. query T SELECT url FROM [EXPLAIN ANALYZE (DISTSQL) SELECT DISTINCT(kw.w) FROM kv JOIN kw ON kv.k = kw.w ORDER BY kw.w] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzMmd1u4kYUx-_7FKO5SlSz9oxtkiCtlHRDVVYpbCEX3a64cPA0WBCb2ibsKsq7V4ZFxJidM7PDMb7D-ON8-uf_mXmh2X9z2qGj7l33wz1ZpnPy-3DwJ_nS_fvT3U2vT276N3ef_-mSs9ve6H701905-X5pcdzrf7gnZ7PVu9X55rbZM_k46PXJbEUGfTJ7fjcj70lxngyGt90h-e3z-mhMLRonoegHTyKjnS-UUYtyalGXWtSjFvXp2KKLNJmILEvS4pKX9Q298CvtOBaN4sUyL_4eW3SSpIJ2Xmge5XNBO_Q-eJiLoQhCkdoOtWgo8iCar83Mnq8XafQUpN-oRUeLIM46pGUXhgfLvEOuCzcegnwyFRlJlvmi-LN4RL5czN_8VVzWG5A8ehId4mTUommyykgqgrA4OX616ObSjeNbxx6-kWmQTcsuXRfXjy2a5cGjoB32av1cpO29SFfVSG32NlZ-8lj5D2PdPWcZJ2koUhGWnjQu7oQuOZCwP4Js-jGJYpHabK815uLf_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U8Phl3LpVjJrm4j2BXI0ZpdCxmqh109fX7xNNi13Togbi3hexvm1pbNiB8FhJFYjkVyQCzrVcyyXsNZFqiLDcueHQzLlkuxkmW9RrAskKM1yxYyVP9m8g5rb0Q6i6NUbP_Tdn7ZydIjggexymUaz5OR-JrEoyXM6nKwXLfcRwlEKldP-eqiF60fpdKXujvSzu6ALOlA34QzUxPeMmRJbNY2Ad-Hnkslh9UYGn6CCs5KlCXHKUu1CWemJhi4v1WWJcHNyxJIDqsxNFtl-d7gfBvceQvu5rCd7cWu0nLPlGp0e08ZoxguxQDguBSjBuduneC4Tc9TVnFbXcVt5eJO3vDtxR31_ydfbQ4Or5_gKh5l5NXYxlk3d99M8Rj6jyxoAHAjtjFvqqe4ikcZGTW2sdTRKUu1CWaKx9B_ZEEDgBsJGvOyPFMyNnPUzYKphwgjzQMrRWC4M2Kb_RUXZBbyYAWMdbiyB0LH1T2sMDvki5kDxaxW_516-wcDJCVuZNXgyGkFxghjSaO1WwCE35hscKsDmXQKE0eF4gYAR97IUYOb6xqt2gTCb6Rv3qE2AfNwt3SYeqBlHaApFEbaKhWOGhx59wZCNx6o9tRXarOwFQ6AjtwKCzNuvphPgWIuzCKNUjiFWaRKhaMGN0oremiQd3WgxBjTkFaTA4zAVTi8zDnqu59KlDlBrby9A9Yhb-1AiTHe29GpTcgI5EMr9djLgbGXF8beChUOAI6scCB0ZE5Ro5sJmf31FWQWrsLhhUE2X8weUMzqs6-aFQ4vzCLvp3DQrUPOuxocWeFAiUGmIQDdmIa0ehgw2NQsMtTW4W7yAODYCgdIDO7pFYRuLG20alM99nJg7OXqIzhkhQOcfCJTC4COrHCAs0_crRoI3Xim31NfqY9cXeDI1S3MGrUqnOHrL_8FAAD__0rC1W4= # This query verifies stats collection for WITH ORDINALITY and the hashJoiner. query T SELECT url FROM [EXPLAIN ANALYZE (DISTSQL) SELECT * FROM kv WITH ORDINALITY AS a, kv WITH ORDINALITY AS b] ---- -https://cockroachdb.github.io/distsqlplan/decode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fcDp12k0KWhR8MpDX0aBjR8e9rveSdV4TljXQTn_NsCTaOkwcNOnn3Z6YpAcYtDsUa1usQrrcp-zXBMe64XBBo73LrDIZbDVWdwF3ZHYX8Pdg9hbxSejm-enrHZO4T9UTg42FxsX_wMAAD__yhd_gE= # Verify that EXPLAIN ANALYZE on an unsupported query doesn't return an error. statement ok @@ -91,7 +91,7 @@ https://cockroachdb.github.io/distsqlplan/decode.html#eJyUkF9LwzAUxd_9FOE-dRBY42 query T SELECT url FROM [EXPLAIN ANALYZE (DISTSQL) SELECT avg(k) OVER () FROM kv] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzMlE2P2jwQx-_Pp7DmBJJRXnkOPkFbWqFS2ALavqxy8MYjGpHEqe2wrBDfvbKz6pIV26ZSVfaY8fxn_r-ZaA6gv-fAYDWZTV6vSa1y8na5-EBuJp-vZuPpnIzn49mXrxPSezNdrVcfZ33ykMp3m962TxbXkyXp9RvVdpcAhVIKnPMCNbAbCIBCCBQioBADhSEkFColU9RaKptycIKp2APzKWRlVRsbTiikUiGwA5jM5AgM1vw2xyVygcrzgYJAw7PctdnuRpXKCq7ugcKq4qVmZODZxovaMDKyNm65Sb-hJrI2lQ3aEqau8pOQTZsuiMkKZMTXQEHJO00UcmEfkyOFJvXBoTZ8g8CCI32G4tF8XUolUKFoGU-OZzg_ZaWQd6i8YRtyfP2uNwr6P6HCtj-brQ3P81P_Bd-TAgup7kmtUTAS--R99qrbOGxF3GNam0yWj1WfG0PYGkPQfZnB75fphQMvusg6w-4cYQeOaODFF-GIunNEHTjigfs9_z1H3J0j7sAxHFz8SJyhWKKuZKnxybE4X9m3RwTFBpuLo2WtUrxSMnVtms-F07mAQG2a16D5mJbuyRk8FQe_FP_fEvtPxeGfdHYojurvLKBtJXo5VuKXY2V4QSvJ8b8fAQAA___RKrUp +https://cockroachdb.github.io/distsqlplan/decode.html#eJzMlE2P2jwQx-_Pp7DmBJJRXnlU-QS0tEKlsAW0fVnl4I1HNCKJU9thQYjvXjnZtmS1dNNDpRwznv_M_zcTzQn09xQYrKfz6esNKVVK3q6WH8jd9PPNfDxbkPFiPP_ydUp6b2brzfrjvE8eU_l-29v1yfJ2uiK9fq3a7SOgkEuBC56hBnYHHlDwgUIAFEKgMISIQqFkjFpLZVNOlWAmDsBcCklelMaGIwqxVAjsBCYxKQKDDb9PcYVcoHJcoCDQ8CSt2uz2o0IlGVdHoLAueK4ZGTi28bI0jIysjXtu4m-oiSxNYYO2hCmL9CJk02ZLYpIMGXG1FR0NaqKQC0ZekQlQUPLhZ8CD6EyhFj961oZvEZh3ple4fuOUuVQCFYoGSnR-hvxTkgv5gMoZNrHHt-96I6__C9Nv-rPZ2vA0vSTK-IFkmEl1JKVGwUjokvfJpN2AbEU8YFyaRObX5hS6ZHJ1Mn5jMl77jXsvb9zxB07QkZ377cn8FmTBwAk7Qha0JwtakIWD6q_uAlnYnixsQTYcdITrhbu6Ql3IXOOTO_R8ZdfeJxRbrI-ZlqWK8UbJuGpTfy4rXRUQqE396tUfs7x6qgxeir0_iv9viN2nYv9vOlcoFdW_WknTXNBlc2GXzQ07ZS46__cjAAD__02r6hs= # Very simple query to make it easier to spot regressions when rewriting results # in test files. diff --git a/pkg/sql/logictest/testdata/logic_test/vectorize_local b/pkg/sql/logictest/testdata/logic_test/vectorize_local index 22c7176d25e7..40eb44a7876f 100644 --- a/pkg/sql/logictest/testdata/logic_test/vectorize_local +++ b/pkg/sql/logictest/testdata/logic_test/vectorize_local @@ -41,17 +41,17 @@ SET vectorize_row_count_threshold = 0 query T SELECT url FROM [EXPLAIN ANALYZE SELECT a FROM a] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJyMkDFPwzAQhXd-hfUmkIxIGD21giBFCk1pOgBVBjc-lUhpbHyOAFX57yhxBxiQGO9775397gR-76BQZUV2txWD78TDpnwUu-x5XSzzlViulsXLayYu7_NqWz0VV-Js1dGoa0j01tBKH4mhdkhRSzhvG2K2fkKn2ZCbT6hEou3dECZcSzTWE9QJoQ0dQWGr9x1tSBvyNwkkDAXddvNavXC-PWr_BYnK6Z6VuIZEOQQlFikk9jo0b8TCDsFNcMqHwXU_0G2STM68FKE9khIJQ8LbDxaetDnr9SgRA-dPctAHgkpH-f8iG2Jne6ZfHf7anIy1BJkDxWOxHXxDa2-b-Zk4lnNuBoY4RDWNQ95HaazHi-8AAAD___mlk0w= +https://cockroachdb.github.io/distsqlplan/decode.html#eJyMkMFO8zAQhO__U6zm9CMZkXDg4FMLBCkiNKXpAahycJNViZTGxnYEVZV3R4mLBAckjvvtzNizR7i3FhJFkiU3a-ptS3er_IE2ydMym6cLmi_m2fNLQv9v02JdPGZndJKqIFQlBDpd80Lt2UFuEKMUMFZX7Jy2IzpOgrT-gIwEms70fsSlQKUtQx7hG98yJNZq2_KKVc32IoJAzV417RSrZsY2e2UPECiM6pykcwjkvZc0iyGwVb56ZUe692aEo9_3pv2GLqNoVKY5-WbPkiI3-g6eHVlWtaT4iu6bawhY_f7FJlM5CISU08-dVzuGjAfx93YrdkZ3jn8U-y05GkoBrnccLuh0byteWl1Nz4Qxn3wTqNn5sI3DkHZhNZTDv88AAAD__7rbmXY= query T SELECT url FROM [EXPLAIN ANALYZE SELECT c.a FROM c JOIN d ON d.b = c.b] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJyUUsuOEzEQvPMVrT6BZEImR0tIiSBIsxpmliQHYDUHx24tBsc2foigaP4dzUMwu2hROHZ1Vbuq5AvG7wY57rfV9s0BcjDwbte8h7vtx9tqU9awqTfVp89beP623B_2H6oXMFHlQoxUCTdNWYOCpga1OMJrkItjiwytU1SLE0Xkd1hgy9AHJylGF3roMhBKdUa-ZKitz6mHW4bSBUJ-waSTIeR4EEdDOxKKwqslMlSUhDbDWbmOJJHh3gsbObxEhk1OHNYFW6-Q4VEk-YUiuJx8j_fylL2ZQT2tbCDpE3FYRmQY3I8IgYTql23HcKRO7mIS94S86Nj1CW6ctlOA4mEAtfZBn0T4iQwr575lD1-dtuAshyHBFOexrcGHMXPb2io6w4xV_Ab_4l7ZC51J5qSd_aN9qo_V__Sxo-idjfSgi6cuL7uWIal7Gn9NdDlIug1ODs-MYzPoBkBRTOO2GIfSjqve4Fxc_FO8eiRuu2e_AgAA__-drQNm +https://cockroachdb.github.io/distsqlplan/decode.html#eJyUUsGO0zAUvPMVT3MCyZSmBw6WkFqgSFmFZGl7AFY5uPbTYkjtYDuiq6r_jpIU1F20q3J882aeZ0Y-IP5sILFeFst3G-pCQx9W1Ue6WX6-LhZ5SYtyUXz5uqTn7_P1Zv2peEEnqp6okarpqspLMlSVZCZbekN6sq0h4LzhUu04Qt4gQy3QBq85Rh966DAQcrOHnApY13aph2sB7QNDHpBsahgSG7VteMXKcHg1hYDhpGwznNXzyBoC61a5KOklBKouSZpnYj6DwFYl_Y0j-S61Pd7LU9c2Z1BPyytKdseSprEX3SWOFFgZSdlreguB4H_9QWaojwKj-mQ4JnXLkNlRXB7qylt3ypTdz2TmbbA7Fe4gUHj_o2vpu7eOvJM0hDolfGhr8NE050msM7ynM1b2F_yHe2FVvGfdJevdk409VtHsfypacWy9i3yvnscuT4-1AJtbHv9W9F3QfB28Hp4Zx2rQDYDhmMZtNg65G1e9wXNx9qR49kBcH5_9DgAA__936A5S query T SELECT url FROM [EXPLAIN ANALYZE SELECT c.a FROM c INNER MERGE JOIN d ON c.a = d.b] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJy0UsFq20AQvfcrhjkldJtIym0hYNOqRcGWUtmHtkGH9e7UEchadXZFU4z_vWgVSBSSlBh607x5bzTvze7R_WpQ4ipdpB_X0HMDn8tiCTfpt-vFPMthns8X33-kcPIpW61XXxencE_VZ2qkasjyPC1hmZZfUrgqshwMFHkgXII521QosLWGcrUjh_IGY6wEdmw1OWd5gPaBkJk7lJHAuu16P8CVQG2ZUO7R174hlLhWm4ZKUob4PEKBhryqmzBWzzqud4r_oMBVp1on4QMKLHovYRajwI3y-pYc2N53Azjofd81j6AEBWYF-HpHEiKHAtn-dsCkzNCsDgJH6v16zqstoYwP4jgL8dSCec1C8l8tJC9aeNi8by0bYjKTratB-S_KMzksibd0ZeuW-DyZ5tDQT38yi9-fXnK9vR0_jzkl3ZHufW3bhzhe8n_xlhOW5DrbOnqaw7OTo8E8mS2NYTrbs6Zrtjr8ZiyLoAuAIefHbjIWWRta4Y09FsdvECdPxcmr4ouJODpUh3d_AwAA___sOVZe +https://cockroachdb.github.io/distsqlplan/decode.html#eJy8kkFv00AQhe_8itGcWrG0titxWKlSAhjkKrGLkwNQ-bDZHVJLjtfMrkWrKP8deV1EU7VB7aE379v3jf3eeIvuV4MSF-ks_biEnhv4XBZzuEq_Xc6mWQ7TfDr7_iOFo0_ZYrn4OjuGO6s-UaNVQ5bnaQnztPySwkWR5WCgyIPhHMzJqkKBrTWUqw05lFcYYyWwY6vJOcuDtA2GzNygjATWbdf7Qa4EasuEcou-9g2hxKVaNVSSMsSnEQo05FXdhLF60nG9UXyLAhedap2Edyiw6L2ESYwCV8rra3Jge98N4sD7vmvuSQkKzArw9YYkRG6Abj05YFJGQvwePqBAtr__KglWO4EjfffFzqs1oYx34mWp4v1U5lCq5LVTJU-m-hemby0bYjJ7QaqB_J_lkWrmxGu6sHVLfJrsV9PQT380id8en3O9vh4fX7JwuiHd-9q2Bxt6qpKz5yy6JNfZ1tHDah6dHA19kFnT2K-zPWu6ZKvDa8ZjEbggGHJ-vE3GQ9aGq_An3ofjZ8DJQzg5CJ_twdGu2r35EwAA__-ut2bA statement ok RESET vectorize; RESET distsql; RESET vectorize_row_count_threshold diff --git a/pkg/sql/opt/exec/execbuilder/testdata/distsql_misc b/pkg/sql/opt/exec/execbuilder/testdata/distsql_misc index bb3f007489b0..48d527de406a 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/distsql_misc +++ b/pkg/sql/opt/exec/execbuilder/testdata/distsql_misc @@ -97,7 +97,7 @@ FROM generate_series(1,10) AS a, generate_series(1,10) AS b, generate_series(1,1 query T SELECT url FROM [EXPLAIN ANALYZE (DISTSQL) CREATE STATISTICS s1 ON a FROM data] ---- -https://cockroachdb.github.io/distsqlplan/decode.html#eJzElUFvm04Qxe__TzGaUyKtAws4cTjF_9SVrLp2aji0jThszMhFxSzdXdSmkb97BdRKHcWwlhLlyMKb9-Y3o-UB9Y8cQ4wms8l1DJXK4f1y8RFuJ59vZuPpHMbz8ezL1wmcvJtGcfRpdgrXy8k4nkAUj-NpFE-vI9AcFnMQrTIVRiTIsJApzcWGNIa3yJGhhwx9ZBggwyEmDEslV6S1VPUnD41gmv7C0GWYFWVl6uOE4UoqwvABTWZywhBjcZfTkkRKynGRYUpGZHljU3tflSrbCHWPDKNSFDqEgcNBFClwkOYbKWS4qEwIV3UoJX9qUCTSELhbV9NG5DmYbEMhuBoZ3t0b2n3in13Ch-x_TLYMZWUeM2oj1oQh3zL7PiKxKXNSznC_h_Y4yn5TE6kJFRnRBj5k7B00fvSrCqlSUpTu-SXbg9HG67WitTBSOdy1DwknnuvCXbX6TkafHozs70Xm9jPnNjN3-MDxbKbu9U_94mx0xNR7OtlN_fzFp-7ZI_SsEHoDx38ThD2d7BBevDhC3x6hb4XQHzjBmyDs6WSHcPTiCAN7hIEVwmDgDG0Q-v0IuXcEwZ5GdgQvX_X2fsZ4SbqUhaYnt_jzld36dqd0Te2vQMtKrehGyVVj0z4uGl1zkJI27VvePkyL9lUd8F8x7xR7e2L-VOx1O_dY-53qoFscHJO7odgA_btFmgoTggvNCu0XHnYWPu9Odf5aqS46C4-6U41eK9Vl9_zdntXrXtxjciXb__4EAAD__1q0grs= +https://cockroachdb.github.io/distsqlplan/decode.html#eJzElkFvm04Qxe__T7GaUyKtAws4djiFf0olVNdODYe2EYeNGbmomKW7i9o08nevgLipoxg2UqwcWXjz3vxmtPY9qB8F-BCHs_AqIbUsyPvl4iO5CT9fz4JoToJ5MPvyNSQn76I4iT_NTsnVMgySkMRJkERxEl3FRDGymBPeKTOueQoUSpHhnG9QgX8DDCg4QMEFCh5QGENKoZJihUoJ2Xxy3wqi7Bf4NoW8rGrdHKcUVkIi-Pegc10g-JDw2wKXyDOUlg0UMtQ8L1qbxvuykvmGyzugEFe8VD4ZWYzwMiOMCP0NJVBY1Nonl00oKX4qIpFnPmF2U01pXhRE5xv0ia2Awu2dxt0n7tkF-ZD_D-mWgqj1Y0al-RrBZ1tq3kfMN1WB0hrv99Adx_lvbCO1oWLNu8CHjJ2Dxo9-dSlkhhKzPb90ezBasF5LXHMtpMVs85DkxLFtcluvvqNWpwcju3uRmfnMmcnMLTayHJOpO8NTn5xNXzD1gU52Uz9_9ak75ggdI4TOyHLfBOFAJzuEk1dH6JojdI0QuiPLexOEA53sEE5fHaFnjtAzQuiNrLEJQncYIXNeQHCgkR3Bi6Pe3s8YL1FVolT45BZ_vrLd3O6YrbH7KVCiliu8lmLV2nSPi1bXHmSodPeWdQ9R2b1qAv4rZr1iZ0_MnoqdfucBa7dX7fWLvZfkbim2QB-2SGGpmz8Bf9dov_i4t_h5f7LzYyab9Baf9iebHjPZRf8u2ANr2L_EZtm8s8lDtnT7358AAAD__8p3hx0= query T SELECT url FROM [EXPLAIN (DISTSQL, TYPES) SELECT * FROM data] From aee051a025f6f1741273c99ebffcfb813b148e82 Mon Sep 17 00:00:00 2001 From: Alfonso Subiotto Marques Date: Mon, 2 Nov 2020 16:24:33 +0100 Subject: [PATCH 2/3] sql: unify saveFlows code and add query types to diagrams and physical plans This commit factors out some repeated code and adds a query type to flow diagrams, which was a TODO when collecting statement bundles in order to be able to differentiate between main queries, postqueries, and subqueries. Release note: None --- pkg/sql/BUILD.bazel | 1 + pkg/sql/conn_executor_exec.go | 10 +------- pkg/sql/distsql_physical_planner.go | 18 ++++++++++++++ pkg/sql/distsql_running.go | 18 ++------------ pkg/sql/explain_bundle.go | 12 ++++------ pkg/sql/explain_bundle_test.go | 2 +- pkg/sql/plan.go | 37 +++++++++++++++++++++++++++-- 7 files changed, 63 insertions(+), 35 deletions(-) diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index 70cc6c635d23..216f3de7f9d0 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -272,6 +272,7 @@ go_library( "//pkg/sql/enum", "//pkg/sql/execinfra", "//pkg/sql/execinfrapb", + "//pkg/sql/execstats", "//pkg/sql/faketreeeval", "//pkg/sql/flowinfra", "//pkg/sql/gcjob/gcjobnotifier", diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go index c9adbcff9865..eb68ef2bd5ff 100644 --- a/pkg/sql/conn_executor_exec.go +++ b/pkg/sql/conn_executor_exec.go @@ -23,7 +23,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/catalog/colinfo" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descs" - "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" "github.com/cockroachdb/cockroach/pkg/sql/paramparse" "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" @@ -965,14 +964,7 @@ func (ex *connExecutor) execWithDistSQLEngine( if ex.server.cfg.TestingKnobs.TestingSaveFlows != nil { planCtx.saveFlows = ex.server.cfg.TestingKnobs.TestingSaveFlows(planner.stmt.SQL) } else if planner.collectBundle { - planCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { - diagram, err := planCtx.flowSpecsToDiagram(ctx, flows) - if err != nil { - return err - } - planner.curPlan.distSQLDiagrams = append(planner.curPlan.distSQLDiagrams, diagram) - return nil - } + planCtx.saveFlows = planCtx.getDefaultSaveFlowsFunc(ctx, planner, planComponentTypeMainQuery) } var evalCtxFactory func() *extendedEvalContext diff --git a/pkg/sql/distsql_physical_planner.go b/pkg/sql/distsql_physical_planner.go index 966f5ab0a55a..3ea8857fa7ae 100644 --- a/pkg/sql/distsql_physical_planner.go +++ b/pkg/sql/distsql_physical_planner.go @@ -30,6 +30,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/distsql" "github.com/cockroachdb/cockroach/pkg/sql/execinfra" "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" + "github.com/cockroachdb/cockroach/pkg/sql/execstats" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/physicalplan" @@ -636,6 +637,23 @@ func (p *PlanningCtx) EvaluateSubqueries() bool { return !p.noEvalSubqueries } +// getDefaultSaveFlowsFunc returns the default function used to save physical +// plans and their diagrams. +func (p *PlanningCtx) getDefaultSaveFlowsFunc( + ctx context.Context, planner *planner, typ planComponentType, +) func(map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + return func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { + diagram, err := p.flowSpecsToDiagram(ctx, flows) + if err != nil { + return err + } + planner.curPlan.distSQLFlowInfos = append( + planner.curPlan.distSQLFlowInfos, flowInfo{typ: typ, diagram: diagram, analyzer: execstats.NewTraceAnalyzer(flows)}, + ) + return nil + } +} + // flowSpecsToDiagram is a helper function used to convert flowSpecs into a // FlowDiagram using this PlanningCtx's information. func (p *PlanningCtx) flowSpecsToDiagram( diff --git a/pkg/sql/distsql_running.go b/pkg/sql/distsql_running.go index de2fb2c8b8ab..b3ad68924107 100644 --- a/pkg/sql/distsql_running.go +++ b/pkg/sql/distsql_running.go @@ -852,14 +852,7 @@ func (dsp *DistSQLPlanner) planAndRunSubquery( subqueryPlanCtx := dsp.NewPlanningCtx(ctx, evalCtx, planner, planner.txn, distributeSubquery) subqueryPlanCtx.stmtType = tree.Rows if planner.collectBundle { - subqueryPlanCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { - diagram, err := subqueryPlanCtx.flowSpecsToDiagram(ctx, flows) - if err != nil { - return err - } - planner.curPlan.distSQLDiagrams = append(planner.curPlan.distSQLDiagrams, diagram) - return nil - } + subqueryPlanCtx.saveFlows = subqueryPlanCtx.getDefaultSaveFlowsFunc(ctx, planner, planComponentTypeSubquery) } // Don't close the top-level plan from subqueries - someone else will handle // that. @@ -1150,14 +1143,7 @@ func (dsp *DistSQLPlanner) planAndRunPostquery( postqueryPlanCtx.stmtType = tree.Rows postqueryPlanCtx.ignoreClose = true if planner.collectBundle { - postqueryPlanCtx.saveFlows = func(flows map[roachpb.NodeID]*execinfrapb.FlowSpec) error { - diagram, err := postqueryPlanCtx.flowSpecsToDiagram(ctx, flows) - if err != nil { - return err - } - planner.curPlan.distSQLDiagrams = append(planner.curPlan.distSQLDiagrams, diagram) - return nil - } + postqueryPlanCtx.saveFlows = postqueryPlanCtx.getDefaultSaveFlowsFunc(ctx, planner, planComponentTypePostquery) } postqueryPhysPlan, err := dsp.createPhysPlan(postqueryPlanCtx, postqueryPlan) diff --git a/pkg/sql/explain_bundle.go b/pkg/sql/explain_bundle.go index 490c88efd5e8..ddb6464026f6 100644 --- a/pkg/sql/explain_bundle.go +++ b/pkg/sql/explain_bundle.go @@ -253,9 +253,9 @@ func (b *stmtBundleBuilder) addExecPlan() { } func (b *stmtBundleBuilder) addDistSQLDiagrams() { - for i, d := range b.plan.distSQLDiagrams { - d.AddSpans(b.trace) - _, url, err := d.ToURL() + for i, d := range b.plan.distSQLFlowInfos { + d.diagram.AddSpans(b.trace) + _, url, err := d.diagram.ToURL() var contents string if err != nil { @@ -265,12 +265,10 @@ func (b *stmtBundleBuilder) addDistSQLDiagrams() { } var filename string - if len(b.plan.distSQLDiagrams) == 1 { + if len(b.plan.distSQLFlowInfos) == 1 { filename = "distsql.html" } else { - // TODO(radu): it would be great if we could distinguish between - // subqueries/main query/postqueries here. - filename = fmt.Sprintf("distsql-%d.html", i+1) + filename = fmt.Sprintf("distsql-%d-%s.html", i+1, d.typ) } b.z.AddFile(filename, contents) } diff --git a/pkg/sql/explain_bundle_test.go b/pkg/sql/explain_bundle_test.go index f3b6ad5afede..7ee1decf7e66 100644 --- a/pkg/sql/explain_bundle_test.go +++ b/pkg/sql/explain_bundle_test.go @@ -66,7 +66,7 @@ func TestExplainAnalyzeDebug(t *testing.T) { rows := r.QueryStr(t, "EXPLAIN ANALYZE (DEBUG) SELECT EXISTS (SELECT * FROM abc WHERE c=1)") checkBundle( t, fmt.Sprint(rows), - base, plans, "stats-defaultdb.public.abc.sql", "distsql-1.html distsql-2.html", + base, plans, "stats-defaultdb.public.abc.sql", "distsql-2-main-query.html distsql-1-subquery.html", ) }) diff --git a/pkg/sql/plan.go b/pkg/sql/plan.go index 85dbeeb0d2cc..73a435342734 100644 --- a/pkg/sql/plan.go +++ b/pkg/sql/plan.go @@ -20,6 +20,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/colinfo" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" + "github.com/cockroachdb/cockroach/pkg/sql/execstats" "github.com/cockroachdb/cockroach/pkg/sql/opt/exec" "github.com/cockroachdb/cockroach/pkg/sql/opt/exec/explain" "github.com/cockroachdb/cockroach/pkg/sql/opt/memo" @@ -267,6 +268,15 @@ type planNodeSpooled interface { var _ planNodeSpooled = &spoolNode{} +type flowInfo struct { + typ planComponentType + diagram execinfrapb.FlowDiagram + // analyzer is a TraceAnalyzer that has been initialized with the + // corresponding flow. Users of this field will want to add a corresponding + // trace in order to calculate statistics. + analyzer *execstats.TraceAnalyzer +} + // planTop is the struct that collects the properties // of an entire plan. // Note: some additional per-statement state is also stored in @@ -301,8 +311,9 @@ type planTop struct { // results. avoidBuffering bool - // If we are collecting query diagnostics, flow diagrams are saved here. - distSQLDiagrams []execinfrapb.FlowDiagram + // If we are collecting query diagnostics, flow information, including + // diagrams, are saved here. + distSQLFlowInfos []flowInfo // If savePlanForStats is true, an ExplainTreePlanNode tree will be saved in // planForStats when the plan is closed. @@ -380,6 +391,28 @@ func (p *planMaybePhysical) Close(ctx context.Context) { } } +type planComponentType int + +const ( + planComponentTypeUnknown = iota + planComponentTypeMainQuery + planComponentTypeSubquery + planComponentTypePostquery +) + +func (t planComponentType) String() string { + switch t { + case planComponentTypeMainQuery: + return "main-query" + case planComponentTypeSubquery: + return "subquery" + case planComponentTypePostquery: + return "postquery" + default: + return "unknownquerytype" + } +} + // planComponents groups together the various components of the entire query // plan. type planComponents struct { From 5ba1ef498e90e3df1d4668d1b213daa421bce421 Mon Sep 17 00:00:00 2001 From: Alfonso Subiotto Marques Date: Mon, 2 Nov 2020 16:24:33 +0100 Subject: [PATCH 3/3] sql/ui: collect and display network bytes sent per statement This commit uses a TraceAnalyzer when statement diagnostics are enabled to populate BytesSentOverNetwork on a per-statement basis. This data is displayed in the corresponding statement's page if collected. This work is a precursor to always-on tracing. Once always-on tracing is enabled, these types of statement statistics calculated from the trace will always be displayed in the admin UI. Release note (admin ui change): If statement diagnostics are enabled for a statement, the bytes sent over the network will be shown in the statement's page. --- pkg/roachpb/app_stats.go | 4 +- pkg/roachpb/app_stats.pb.go | 254 +++++++++++------- pkg/roachpb/app_stats.proto | 3 + pkg/sql/app_stats.go | 5 + pkg/sql/conn_executor_exec.go | 31 +++ .../src/views/statements/statementDetails.tsx | 12 +- 6 files changed, 203 insertions(+), 106 deletions(-) diff --git a/pkg/roachpb/app_stats.go b/pkg/roachpb/app_stats.go index 70096ebca5af..71292693c162 100644 --- a/pkg/roachpb/app_stats.go +++ b/pkg/roachpb/app_stats.go @@ -129,6 +129,7 @@ func (s *StatementStatistics) Add(other *StatementStatistics) { s.OverheadLat.Add(other.OverheadLat, s.Count, other.Count) s.BytesRead.Add(other.BytesRead, s.Count, other.Count) s.RowsRead.Add(other.RowsRead, s.Count, other.Count) + s.BytesSentOverNetwork.Add(other.BytesSentOverNetwork, s.Count, other.Count) if other.SensitiveInfo.LastErr != "" { s.SensitiveInfo.LastErr = other.SensitiveInfo.LastErr @@ -155,5 +156,6 @@ func (s *StatementStatistics) AlmostEqual(other *StatementStatistics, eps float6 s.OverheadLat.AlmostEqual(other.OverheadLat, eps) && s.SensitiveInfo.Equal(other.SensitiveInfo) && s.BytesRead.AlmostEqual(other.BytesRead, eps) && - s.RowsRead.AlmostEqual(other.RowsRead, eps) + s.RowsRead.AlmostEqual(other.RowsRead, eps) && + s.BytesSentOverNetwork.AlmostEqual(other.BytesSentOverNetwork, eps) } diff --git a/pkg/roachpb/app_stats.pb.go b/pkg/roachpb/app_stats.pb.go index 305d351b7d95..f6c7eef437a2 100644 --- a/pkg/roachpb/app_stats.pb.go +++ b/pkg/roachpb/app_stats.pb.go @@ -79,13 +79,15 @@ type StatementStatistics struct { BytesRead NumericStat `protobuf:"bytes,15,opt,name=bytes_read,json=bytesRead" json:"bytes_read"` // RowsRead collects the number of rows read from disk. RowsRead NumericStat `protobuf:"bytes,16,opt,name=rows_read,json=rowsRead" json:"rows_read"` + // BytesSentOverNetwork collects the number of bytes sent over the network. + BytesSentOverNetwork NumericStat `protobuf:"bytes,17,opt,name=bytes_sent_over_network,json=bytesSentOverNetwork" json:"bytes_sent_over_network"` } func (m *StatementStatistics) Reset() { *m = StatementStatistics{} } func (m *StatementStatistics) String() string { return proto.CompactTextString(m) } func (*StatementStatistics) ProtoMessage() {} func (*StatementStatistics) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{0} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{0} } func (m *StatementStatistics) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -134,7 +136,7 @@ func (m *TransactionStatistics) Reset() { *m = TransactionStatistics{} } func (m *TransactionStatistics) String() string { return proto.CompactTextString(m) } func (*TransactionStatistics) ProtoMessage() {} func (*TransactionStatistics) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{1} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{1} } func (m *TransactionStatistics) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -174,7 +176,7 @@ func (m *SensitiveInfo) Reset() { *m = SensitiveInfo{} } func (m *SensitiveInfo) String() string { return proto.CompactTextString(m) } func (*SensitiveInfo) ProtoMessage() {} func (*SensitiveInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{2} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{2} } func (m *SensitiveInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -216,7 +218,7 @@ func (m *NumericStat) Reset() { *m = NumericStat{} } func (m *NumericStat) String() string { return proto.CompactTextString(m) } func (*NumericStat) ProtoMessage() {} func (*NumericStat) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{3} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{3} } func (m *NumericStat) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -255,7 +257,7 @@ func (m *StatementStatisticsKey) Reset() { *m = StatementStatisticsKey{} func (m *StatementStatisticsKey) String() string { return proto.CompactTextString(m) } func (*StatementStatisticsKey) ProtoMessage() {} func (*StatementStatisticsKey) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{4} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{4} } func (m *StatementStatisticsKey) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -295,7 +297,7 @@ func (m *CollectedStatementStatistics) Reset() { *m = CollectedStatement func (m *CollectedStatementStatistics) String() string { return proto.CompactTextString(m) } func (*CollectedStatementStatistics) ProtoMessage() {} func (*CollectedStatementStatistics) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{5} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{5} } func (m *CollectedStatementStatistics) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -335,7 +337,7 @@ func (m *CollectedTransactionStatistics) Reset() { *m = CollectedTransac func (m *CollectedTransactionStatistics) String() string { return proto.CompactTextString(m) } func (*CollectedTransactionStatistics) ProtoMessage() {} func (*CollectedTransactionStatistics) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{6} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{6} } func (m *CollectedTransactionStatistics) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -375,7 +377,7 @@ func (m *ExplainTreePlanNode) Reset() { *m = ExplainTreePlanNode{} } func (m *ExplainTreePlanNode) String() string { return proto.CompactTextString(m) } func (*ExplainTreePlanNode) ProtoMessage() {} func (*ExplainTreePlanNode) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{7} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{7} } func (m *ExplainTreePlanNode) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -409,7 +411,7 @@ func (m *ExplainTreePlanNode_Attr) Reset() { *m = ExplainTreePlanNode_At func (m *ExplainTreePlanNode_Attr) String() string { return proto.CompactTextString(m) } func (*ExplainTreePlanNode_Attr) ProtoMessage() {} func (*ExplainTreePlanNode_Attr) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{7, 0} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{7, 0} } func (m *ExplainTreePlanNode_Attr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -448,7 +450,7 @@ func (m *TxnStats) Reset() { *m = TxnStats{} } func (m *TxnStats) String() string { return proto.CompactTextString(m) } func (*TxnStats) ProtoMessage() {} func (*TxnStats) Descriptor() ([]byte, []int) { - return fileDescriptor_app_stats_82983606d1915ef5, []int{8} + return fileDescriptor_app_stats_02e0c72cac47fa1c, []int{8} } func (m *TxnStats) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -688,6 +690,16 @@ func (m *StatementStatistics) MarshalTo(dAtA []byte) (int, error) { return 0, err } i += n9 + dAtA[i] = 0x8a + i++ + dAtA[i] = 0x1 + i++ + i = encodeVarintAppStats(dAtA, i, uint64(m.BytesSentOverNetwork.Size())) + n10, err := m.BytesSentOverNetwork.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n10 return i, nil } @@ -715,35 +727,35 @@ func (m *TransactionStatistics) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintAppStats(dAtA, i, uint64(m.NumRows.Size())) - n10, err := m.NumRows.MarshalTo(dAtA[i:]) + n11, err := m.NumRows.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n11 dAtA[i] = 0x22 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.ServiceLat.Size())) - n11, err := m.ServiceLat.MarshalTo(dAtA[i:]) + n12, err := m.ServiceLat.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n12 dAtA[i] = 0x2a i++ i = encodeVarintAppStats(dAtA, i, uint64(m.RetryLat.Size())) - n12, err := m.RetryLat.MarshalTo(dAtA[i:]) + n13, err := m.RetryLat.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n13 dAtA[i] = 0x32 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.CommitLat.Size())) - n13, err := m.CommitLat.MarshalTo(dAtA[i:]) + n14, err := m.CommitLat.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n13 + i += n14 return i, nil } @@ -769,19 +781,19 @@ func (m *SensitiveInfo) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.MostRecentPlanDescription.Size())) - n14, err := m.MostRecentPlanDescription.MarshalTo(dAtA[i:]) + n15, err := m.MostRecentPlanDescription.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n15 dAtA[i] = 0x1a i++ i = encodeVarintAppStats(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.MostRecentPlanTimestamp))) - n15, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.MostRecentPlanTimestamp, dAtA[i:]) + n16, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.MostRecentPlanTimestamp, dAtA[i:]) if err != nil { return 0, err } - i += n15 + i += n16 return i, nil } @@ -895,19 +907,19 @@ func (m *CollectedStatementStatistics) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintAppStats(dAtA, i, uint64(m.Key.Size())) - n16, err := m.Key.MarshalTo(dAtA[i:]) + n17, err := m.Key.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n16 + i += n17 dAtA[i] = 0x12 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.Stats.Size())) - n17, err := m.Stats.MarshalTo(dAtA[i:]) + n18, err := m.Stats.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n18 dAtA[i] = 0x18 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.ID)) @@ -943,11 +955,11 @@ func (m *CollectedTransactionStatistics) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintAppStats(dAtA, i, uint64(m.Stats.Size())) - n18, err := m.Stats.MarshalTo(dAtA[i:]) + n19, err := m.Stats.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n18 + i += n19 return i, nil } @@ -1044,11 +1056,11 @@ func (m *TxnStats) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.TxnTimeSec.Size())) - n19, err := m.TxnTimeSec.MarshalTo(dAtA[i:]) + n20, err := m.TxnTimeSec.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n20 dAtA[i] = 0x18 i++ i = encodeVarintAppStats(dAtA, i, uint64(m.CommittedCount)) @@ -1098,6 +1110,8 @@ func (m *StatementStatistics) Size() (n int) { n += 1 + l + sovAppStats(uint64(l)) l = m.RowsRead.Size() n += 2 + l + sovAppStats(uint64(l)) + l = m.BytesSentOverNetwork.Size() + n += 2 + l + sovAppStats(uint64(l)) return n } @@ -1673,6 +1687,36 @@ func (m *StatementStatistics) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BytesSentOverNetwork", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAppStats + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAppStats + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BytesSentOverNetwork.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAppStats(dAtA[iNdEx:]) @@ -3123,78 +3167,80 @@ var ( ErrIntOverflowAppStats = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("roachpb/app_stats.proto", fileDescriptor_app_stats_82983606d1915ef5) } - -var fileDescriptor_app_stats_82983606d1915ef5 = []byte{ - // 1113 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xbd, 0x6e, 0x1b, 0x47, - 0x17, 0xd5, 0xf2, 0x47, 0x24, 0x2f, 0x49, 0xc9, 0xdf, 0xf8, 0x6f, 0x3f, 0x42, 0x20, 0x15, 0xc2, - 0x86, 0x65, 0x24, 0xa1, 0x00, 0x21, 0x4d, 0x12, 0xc8, 0xb2, 0x28, 0xb9, 0xa0, 0x23, 0x18, 0x09, - 0xa5, 0x2a, 0xcd, 0x62, 0xb4, 0x7b, 0x29, 0x0d, 0xb4, 0x7f, 0x9a, 0x19, 0xd2, 0x64, 0x9f, 0x07, - 0xf0, 0x23, 0xe4, 0x3d, 0x52, 0xa6, 0x51, 0x93, 0xc0, 0xa5, 0x91, 0x42, 0x49, 0xa8, 0x26, 0x4f, - 0x90, 0x22, 0x55, 0x30, 0x33, 0xbb, 0x0c, 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82, 0x92, 0x1c, 0x86, 0xce, 0xfb, 0x2f, 0x42, 0x51, 0x0e, - 0x43, 0xf3, 0xc5, 0xd4, 0x86, 0x8a, 0x82, 0xa8, 0x11, 0xe2, 0x08, 0x74, 0x13, 0x4f, 0x2d, 0x31, - 0xb1, 0xe5, 0x50, 0x8f, 0x8c, 0x63, 0x74, 0xc9, 0xa7, 0xb0, 0x6e, 0xc6, 0xa7, 0x44, 0x2f, 0x59, - 0x6c, 0xfa, 0xcb, 0x6b, 0x6d, 0x92, 0x34, 0x4b, 0x7e, 0x0c, 0x6b, 0x93, 0x06, 0x33, 0xe8, 0xdc, - 0x14, 0xba, 0x9a, 0xe6, 0x34, 0xb8, 0xfd, 0xf4, 0xea, 0xf7, 0xfa, 0xca, 0xd5, 0xb8, 0x6e, 0xbd, - 0x1d, 0xd7, 0xad, 0x77, 0xe3, 0xba, 0xf5, 0xdb, 0xb8, 0x6e, 0xbd, 0xb9, 0xa9, 0xaf, 0xbc, 0xbd, - 0xa9, 0xaf, 0xbc, 0xbb, 0xa9, 0xaf, 0x7c, 0x5b, 0x48, 0x3e, 0x5e, 0xff, 0x0e, 0x00, 0x00, 0xff, - 0xff, 0xea, 0x08, 0x8c, 0xbf, 0xc6, 0x0a, 0x00, 0x00, +func init() { proto.RegisterFile("roachpb/app_stats.proto", fileDescriptor_app_stats_02e0c72cac47fa1c) } + +var fileDescriptor_app_stats_02e0c72cac47fa1c = []byte{ + // 1145 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0x23, 0x45, + 0x10, 0xce, 0xf8, 0x27, 0xb6, 0xcb, 0x76, 0xb2, 0x3b, 0xfb, 0x37, 0x58, 0x91, 0x1d, 0xac, 0x5d, + 0x6d, 0x56, 0x80, 0x23, 0x45, 0x5c, 0x00, 0x65, 0x7f, 0x9c, 0xec, 0xc1, 0x4b, 0x14, 0xc0, 0x8e, + 0x84, 0xc4, 0x65, 0xd4, 0x99, 0x29, 0x27, 0xad, 0xcc, 0x5f, 0xba, 0xdb, 0x8e, 0x7d, 0xe7, 0x01, + 0xf6, 0x11, 0xb8, 0xf1, 0x10, 0x1c, 0xb9, 0xe4, 0x82, 0xb4, 0xc7, 0x15, 0x87, 0x00, 0xce, 0x85, + 0x27, 0xe0, 0xc0, 0x09, 0x75, 0xf7, 0x8c, 0xb1, 0xbd, 0x8e, 0x98, 0xe5, 0x66, 0x57, 0xd5, 0xf7, + 0x75, 0x57, 0xd5, 0x57, 0xd5, 0x03, 0x0f, 0x58, 0x48, 0x9c, 0xd3, 0xe8, 0x78, 0x9b, 0x44, 0x91, + 0xcd, 0x05, 0x11, 0xbc, 0x15, 0xb1, 0x50, 0x84, 0x66, 0xd5, 0x09, 0x9d, 0x33, 0xe5, 0x6c, 0xf1, + 0x73, 0xaf, 0x76, 0xf7, 0x24, 0x3c, 0x09, 0x95, 0x67, 0x5b, 0xfe, 0xd2, 0x41, 0xb5, 0xc6, 0x49, + 0x18, 0x9e, 0x78, 0xb8, 0xad, 0xfe, 0x1d, 0x0f, 0xfa, 0xdb, 0x82, 0xfa, 0xc8, 0x05, 0xf1, 0x23, + 0x1d, 0xd0, 0xfc, 0xb1, 0x00, 0x77, 0x7a, 0x82, 0x08, 0xf4, 0x31, 0x10, 0xf2, 0x07, 0xe5, 0x82, + 0x3a, 0xdc, 0xac, 0x41, 0xde, 0x09, 0x07, 0x81, 0xb0, 0x8c, 0x4d, 0x63, 0x2b, 0xdb, 0xce, 0x5d, + 0x5e, 0x35, 0x56, 0xba, 0xda, 0x64, 0x7e, 0x0a, 0x77, 0xfa, 0x94, 0x71, 0x61, 0x13, 0x21, 0xd0, + 0x8f, 0x84, 0xad, 0x23, 0x33, 0x33, 0x91, 0xb7, 0x55, 0xc0, 0x0b, 0xed, 0xdf, 0x53, 0xa8, 0x47, + 0x50, 0xf6, 0xc9, 0xc8, 0x66, 0x28, 0x18, 0x45, 0x6e, 0x65, 0x67, 0xa2, 0xc1, 0x27, 0xa3, 0xae, + 0xb6, 0x9b, 0x1f, 0xc3, 0xba, 0x87, 0x27, 0xc4, 0x19, 0xdb, 0x1e, 0xe1, 0xc2, 0x46, 0xc6, 0xac, + 0xdc, 0xa6, 0xb1, 0x55, 0x8a, 0x43, 0xab, 0xda, 0x79, 0x40, 0xb8, 0x78, 0xc9, 0x98, 0xf9, 0x05, + 0x14, 0x83, 0x81, 0x6f, 0xb3, 0xf0, 0x82, 0x5b, 0xf9, 0x4d, 0x63, 0xab, 0xbc, 0x53, 0x6b, 0xcd, + 0xd5, 0xa5, 0x75, 0x38, 0xf0, 0x91, 0x51, 0x47, 0xa6, 0x16, 0x53, 0x14, 0x82, 0x81, 0xdf, 0x0d, + 0x2f, 0xb8, 0xb9, 0x0b, 0xa5, 0x88, 0x30, 0x8e, 0xb6, 0x47, 0x84, 0xb5, 0x9a, 0x12, 0x5d, 0x54, + 0x90, 0x03, 0x22, 0xe4, 0xd9, 0x91, 0x47, 0x02, 0x85, 0x2e, 0xa4, 0x3d, 0x5b, 0x22, 0x24, 0xf8, + 0x33, 0x28, 0xb0, 0x81, 0xc6, 0x16, 0x53, 0x62, 0x57, 0xd9, 0x40, 0x41, 0x5f, 0x40, 0x99, 0x23, + 0x1b, 0x52, 0x47, 0x5f, 0xbc, 0x94, 0x12, 0x0e, 0x31, 0x48, 0x52, 0xec, 0x41, 0x25, 0x1c, 0x22, + 0x3b, 0x45, 0xe2, 0x2a, 0x0e, 0x48, 0xc9, 0x51, 0x4e, 0x50, 0x92, 0x64, 0x17, 0xac, 0x85, 0x4e, + 0xd9, 0x0c, 0x5d, 0xe2, 0x08, 0x74, 0xad, 0xf2, 0x4c, 0xcb, 0xee, 0xcd, 0xb5, 0xac, 0x1b, 0x87, + 0x98, 0x1d, 0x58, 0xe3, 0x18, 0x70, 0x2a, 0xe8, 0x10, 0x6d, 0x1a, 0xf4, 0x43, 0xab, 0xa2, 0x6e, + 0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achpb/app_stats.proto b/pkg/roachpb/app_stats.proto index 9104c6f48477..690f6016a662 100644 --- a/pkg/roachpb/app_stats.proto +++ b/pkg/roachpb/app_stats.proto @@ -86,6 +86,9 @@ message StatementStatistics { // RowsRead collects the number of rows read from disk. optional NumericStat rows_read = 16 [(gogoproto.nullable) = false]; + // BytesSentOverNetwork collects the number of bytes sent over the network. + optional NumericStat bytes_sent_over_network = 17 [(gogoproto.nullable) = false]; + // Note: be sure to update `sql/app_stats.go` when adding/removing fields here! } diff --git a/pkg/sql/app_stats.go b/pkg/sql/app_stats.go index 1dd96ff89124..68b7ebeedcc6 100644 --- a/pkg/sql/app_stats.go +++ b/pkg/sql/app_stats.go @@ -220,6 +220,11 @@ func (a *appStats) recordStatement( s.mu.data.OverheadLat.Record(s.mu.data.Count, ovhLat) s.mu.data.BytesRead.Record(s.mu.data.Count, float64(stats.bytesRead)) s.mu.data.RowsRead.Record(s.mu.data.Count, float64(stats.rowsRead)) + // Note that some fields derived from tracing statements (such as + // BytesSentOverNetwork) are not updated here because they are collected + // on-demand. + // TODO(asubiotto): Record the aforementioned fields here when always-on + // tracing is a thing. s.mu.vectorized = vectorized s.mu.distSQLUsed = distSQLUsed s.mu.Unlock() diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go index eb68ef2bd5ff..ac772bf5db02 100644 --- a/pkg/sql/conn_executor_exec.go +++ b/pkg/sql/conn_executor_exec.go @@ -379,6 +379,37 @@ func (ex *connExecutor) execStmtInOpenState( ) } } + + stmtStats, _ := ex.appStats.getStatsForStmt(&stmt, ex.implicitTxn(), retErr, false) + if stmtStats == nil { + return + } + + networkBytesSent := int64(0) + for _, flowInfo := range p.curPlan.distSQLFlowInfos { + analyzer := flowInfo.analyzer + if err := analyzer.AddTrace(trace); err != nil { + log.VInfof(ctx, 1, "error analyzing trace statistics for stmt %s: %v", stmt, err) + continue + } + + networkBytesSentGroupedByNode, err := analyzer.GetNetworkBytesSent() + if err != nil { + log.VInfof(ctx, 1, "error calculating network bytes sent for stmt %s: %v", stmt, err) + continue + } + for _, bytesSentByNode := range networkBytesSentGroupedByNode { + networkBytesSent += bytesSentByNode + } + } + + stmtStats.mu.Lock() + // Record trace-related statistics. A count of 1 is passed given that this + // statistic is only recorded when statement diagnostics are enabled. + // TODO(asubiotto): NumericStat properties will be properly calculated + // once this statistic is always collected. + stmtStats.mu.data.BytesSentOverNetwork.Record(1 /* count */, float64(networkBytesSent)) + stmtStats.mu.Unlock() }() } diff --git a/pkg/ui/src/views/statements/statementDetails.tsx b/pkg/ui/src/views/statements/statementDetails.tsx index 0437fcd8a32e..72f0aa6811fb 100644 --- a/pkg/ui/src/views/statements/statementDetails.tsx +++ b/pkg/ui/src/views/statements/statementDetails.tsx @@ -500,7 +500,17 @@ export class StatementDetails extends React.Component r.value)} + { + name: "Network Bytes Sent", value: stats.bytes_sent_over_network, bar: genericBarChart(stats.bytes_sent_over_network, stats.count, Bytes), + format: Bytes, + }, + ].filter(function (r) { + if (r.name === "Network Bytes Sent" && r.value.mean === 0) { + // Omit if empty. + return false; + } + return r.value; + })} />