Skip to content

Commit 8d84db0

Browse files
committed
sql, sqltelemetry: add telemetry counter for external statement hints
Informs: #153633 Release note: None
1 parent 3dd8853 commit 8d84db0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pkg/sql/conn_executor_exec.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ func (ex *connExecutor) execStmtInOpenState(
574574
ast = stmt.Statement.AST
575575
}
576576

577+
if len(stmt.Hints) > 0 {
578+
telemetry.Inc(sqltelemetry.StatementHintsCounter)
579+
}
580+
577581
// This goroutine is the only one that can modify txnState.mu.priority and
578582
// txnState.mu.autoRetryCounter, so we don't need to get a mutex here.
579583
ctx = ih.Setup(ctx, ex, p, &stmt, os.ImplicitTxn.Get(),
@@ -1474,6 +1478,10 @@ func (ex *connExecutor) execStmtInOpenStateWithPausablePortal(
14741478
vars.ast = vars.stmt.Statement.AST
14751479
}
14761480

1481+
if len(vars.stmt.Hints) > 0 {
1482+
telemetry.Inc(sqltelemetry.StatementHintsCounter)
1483+
}
1484+
14771485
// For pausable portal, the instrumentation helper needs to be set up only
14781486
// when the portal is executed for the first time.
14791487
//

pkg/sql/sqltelemetry/planning.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ var PlanClampedHistogramSelectivityCounter = telemetry.GetCounterOnce("sql.plan.
234234
// a histogram to a minimum value.
235235
var PlanClampedInequalitySelectivityCounter = telemetry.GetCounterOnce("sql.plan.clamped-inequality-selectivity")
236236

237+
// StatementHintsCounter is to be incremented whenever external statement hints
238+
// are used.
239+
var StatementHintsCounter = telemetry.GetCounterOnce("sql.session.statement-hints")
240+
237241
// We can't parameterize these telemetry counters, so just make a bunch of
238242
// buckets for setting the join reorder limit since the range of reasonable
239243
// values for the join reorder limit is quite small.

0 commit comments

Comments
 (0)