func (a *appStats) recordStatement(
	stmt *Statement,
	samplePlanDescription *roachpb.ExplainTreePlanNode,
	distSQLUsed bool,
	vectorized bool,
	implicitTxn bool,
	automaticRetryCount int,
	numRows int,
	err error,
	parseLat, planLat, runLat, svcLat, ovhLat float64,
	stats topLevelQueryStats,
) {
	if !stmtStatsEnable.Get(&a.st.SV) {
		return
	}

	if t := sqlStatsCollectionLatencyThreshold.Get(&a.st.SV); t > 0 && t.Seconds() >= svcLat {
		return
	}

	// Get the statistics object.
	s := a.getStatsForStmt(
		stmt, distSQLUsed, vectorized, implicitTxn,
		err, true, /* createIfNonexistent */
	)

	// Collect the per-statement statistics.
	s.Lock()
	s.data.Count++
	if err != nil {
		s.data.SensitiveInfo.LastErr = err.Error()
	}
	// Only update MostRecentPlanDescription if we sampled a new PlanDescription.
	if samplePlanDescription != nil {
		s.data.SensitiveInfo.MostRecentPlanDescription = *samplePlanDescription
		s.data.SensitiveInfo.MostRecentPlanTimestamp = timeutil.Now()
	}
	if automaticRetryCount == 0 {
		s.data.FirstAttemptCount++
	} else if int64(automaticRetryCount) > s.data.MaxRetries {
		s.data.MaxRetries = int64(automaticRetryCount)
	}
	s.data.NumRows.Record(s.data.Count, float64(numRows))
	s.data.ParseLat.Record(s.data.Count, parseLat)
	s.data.PlanLat.Record(s.data.Count, planLat)
	s.data.RunLat.Record(s.data.Count, runLat)
	s.data.ServiceLat.Record(s.data.Count, svcLat)
	s.data.OverheadLat.Record(s.data.Count, ovhLat)
	s.data.BytesRead.Record(s.data.Count, float64(stats.bytesRead))
	s.data.RowsRead.Record(s.data.Count, float64(stats.rowsRead))
	s.Unlock()
}
// recordStatement saves per-statement statistics.
//
// samplePlanDescription can be nil, as these are only sampled periodically per unique fingerprint.
recordStatement saves per-statement statistics.

samplePlanDescription can be nil, as these are only sampled periodically per unique fingerprint.
// recordStatement saves per - statement statistics . // // samplePlanDescription can be nil as these are only sampled periodically per unique fingerprint .
func (a *appStats) recordStatement(
	stmt *Statement,
	samplePlanDescription *roachpb.ExplainTreePlanNode,
	distSQLUsed bool,
	vectorized bool,
	implicitTxn bool,
	automaticRetryCount int,
	numRows int,
	err error,
	parseLat, planLat, runLat, svcLat, ovhLat float64,
	stats topLevelQueryStats,
) {
	if !stmtStatsEnable.Get(&a.st.SV) {
		return
	}
	if t := sqlStatsCollectionLatencyThreshold.Get(&a.st.SV); t > 0 && t.Seconds() >= svcLat {
		return
	}
	s := a.getStatsForStmt(
		stmt, distSQLUsed, vectorized, implicitTxn,
		err, true, 
	)
	s.Lock()
	s.data.Count++
	if err != nil {
		s.data.SensitiveInfo.LastErr = err.Error()
	}
	if samplePlanDescription != nil {
		s.data.SensitiveInfo.MostRecentPlanDescription = *samplePlanDescription
		s.data.SensitiveInfo.MostRecentPlanTimestamp = timeutil.Now()
	}
	if automaticRetryCount == 0 {
		s.data.FirstAttemptCount++
	} else if int64(automaticRetryCount) > s.data.MaxRetries {
		s.data.MaxRetries = int64(automaticRetryCount)
	}
	s.data.NumRows.Record(s.data.Count, float64(numRows))
	s.data.ParseLat.Record(s.data.Count, parseLat)
	s.data.PlanLat.Record(s.data.Count, planLat)
	s.data.RunLat.Record(s.data.Count, runLat)
	s.data.ServiceLat.Record(s.data.Count, svcLat)
	s.data.OverheadLat.Record(s.data.Count, ovhLat)
	s.data.BytesRead.Record(s.data.Count, float64(stats.bytesRead))
	s.data.RowsRead.Record(s.data.Count, float64(stats.rowsRead))
	s.Unlock()
}
func ( a * appStats ) recordStatement ( stmt * Statement , samplePlanDescription * roachpb . ExplainTreePlanNode , distSQLUsed bool , vectorized bool , implicitTxn bool , automaticRetryCount int , numRows int , err error , parseLat , planLat , runLat , svcLat , ovhLat float64 , stats topLevelQueryStats , ) { if ! stmtStatsEnable . Get ( & a . st . SV ) { return } if t := sqlStatsCollectionLatencyThreshold . Get ( & a . st . SV ) ; t > 0 && t . Seconds ( ) >= svcLat { return } s := a . getStatsForStmt ( stmt , distSQLUsed , vectorized , implicitTxn , err , true , ) s . Lock ( ) s . data . Count ++ if err != nil { s . data . SensitiveInfo . LastErr = err . Error ( ) } if samplePlanDescription != nil { s . data . SensitiveInfo . MostRecentPlanDescription = * samplePlanDescription s . data . SensitiveInfo . MostRecentPlanTimestamp = timeutil . Now ( ) } if automaticRetryCount == 0 { s . data . FirstAttemptCount ++ } else if int64 ( automaticRetryCount ) > s . data . MaxRetries { s . data . MaxRetries = int64 ( automaticRetryCount ) } s . data . NumRows . Record ( s . data . Count , float64 ( numRows ) ) s . data . ParseLat . Record ( s . data . Count , parseLat ) s . data . PlanLat . Record ( s . data . Count , planLat ) s . data . RunLat . Record ( s . data . Count , runLat ) s . data . ServiceLat . Record ( s . data . Count , svcLat ) s . data . OverheadLat . Record ( s . data . Count , ovhLat ) s . data . BytesRead . Record ( s . data . Count , float64 ( stats . bytesRead ) ) s . data . RowsRead . Record ( s . data . Count , float64 ( stats . rowsRead ) ) s . Unlock ( ) }
recordStatement saves per-statement statistics.
recordStatement saves per - statement statistics .
// Get the statistics object. /* createIfNonexistent */ // Collect the per-statement statistics. // Only update MostRecentPlanDescription if we sampled a new PlanDescription.