Skip to content

Commit f8a4192

Browse files
committed
sql: replace statement fingerprint id construction with fingerprint id from instrumentation helper
The instrumentation helper now generates a statement fingerprint id in its setup function and stores it in its state. Now, when fingerprint ids are needed for sql stats collection or telemetry logging, the fingerprint id from the instrumentation helper is used. Epic: None Release note: None
1 parent 9827e62 commit f8a4192

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

pkg/sql/exec_log.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -347,23 +347,7 @@ func (p *planner) maybeLogStatementInternal(
347347
// overhead latency: txn/retry management, error checking, etc
348348
execOverheadNanos := svcLatNanos - processingLatNanos
349349

350-
// If the statement was recorded by the stats collector, we can extract
351-
// the statement fingerprint ID. Otherwise, we'll need to compute it from the AST.
352-
stmtFingerprintID := statsCollector.StatementFingerprintID()
353-
if stmtFingerprintID == 0 {
354-
repQuery := p.stmt.StmtNoConstants
355-
if repQuery == "" {
356-
flags := tree.FmtFlags(tree.QueryFormattingForFingerprintsMask.Get(&p.execCfg.Settings.SV))
357-
f := tree.NewFmtCtx(flags)
358-
f.FormatNode(p.stmt.AST)
359-
repQuery = f.CloseAndGetString()
360-
}
361-
stmtFingerprintID = appstatspb.ConstructStatementFingerprintID(
362-
repQuery,
363-
implicitTxn,
364-
p.CurrentDatabase(),
365-
)
366-
}
350+
stmtFingerprintID := p.instrumentation.fingerprintId
367351

368352
sampledQuery := getSampledQuery()
369353
defer releaseSampledQuery(sampledQuery)

pkg/sql/executor_statement_metrics.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ func (ex *connExecutor) recordStatementSummary(
191191
}
192192
startTime := phaseTimes.GetSessionPhaseTime(sessionphase.PlannerStartExecStmt).ToUTC()
193193
implicitTxn := flags.IsSet(planFlagImplicitTxn)
194-
stmtFingerprintID := appstatspb.ConstructStatementFingerprintID(
195-
stmt.StmtNoConstants, implicitTxn, planner.SessionData().Database)
194+
stmtFingerprintID := planner.instrumentation.fingerprintId
196195
autoRetryReason := ex.state.mu.autoRetryReason
197196
if automaticRetryStmtCount > 0 {
198197
autoRetryReason = planner.autoRetryStmtReason

0 commit comments

Comments
 (0)