Skip to content

Commit

Permalink
sql: rename anonymizedStmt in sqlstats pkg to stmtNoConstants
Browse files Browse the repository at this point in the history
This commit changes all instances of anonymizedStmt to stmtNoConstants in
the sqlstats package.

The commit does not change any files outside the sqlstats package.

Fixes #80725.

Release note: None
  • Loading branch information
ericharmeling committed Jun 28, 2022
1 parent 443c4d5 commit c9267e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/sqlstats/ssmemstorage/ss_mem_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *StmtStatsIterator) Next() bool {

s.currentValue = &roachpb.CollectedStatementStatistics{
Key: roachpb.StatementStatisticsKey{
Query: stmtKey.anonymizedStmt,
Query: stmtKey.stmtNoConstants,
QuerySummary: querySummary,
DistSQL: distSQLUsed,
Vec: vectorized,
Expand Down
42 changes: 21 additions & 21 deletions pkg/sql/sqlstats/ssmemstorage/ss_mem_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ type stmtKey struct {

// sampledPlanKey is used by the Optimizer to determine if we should build a full EXPLAIN plan.
type sampledPlanKey struct {
anonymizedStmt string
failed bool
implicitTxn bool
database string
stmtNoConstants string
failed bool
implicitTxn bool
database string
}

func (p sampledPlanKey) size() int64 {
return int64(unsafe.Sizeof(p)) + int64(len(p.anonymizedStmt)) + int64(len(p.database))
return int64(unsafe.Sizeof(p)) + int64(len(p.stmtNoConstants)) + int64(len(p.database))
}

func (s stmtKey) String() string {
if s.failed {
return "!" + s.anonymizedStmt
return "!" + s.stmtNoConstants
}
return s.anonymizedStmt
return s.stmtNoConstants
}

func (s stmtKey) size() int64 {
Expand Down Expand Up @@ -259,10 +259,10 @@ func NewTempContainerFromExistingStmtStats(
}
key := stmtKey{
sampledPlanKey: sampledPlanKey{
anonymizedStmt: statistics[i].Key.KeyData.Query,
failed: statistics[i].Key.KeyData.Failed,
implicitTxn: statistics[i].Key.KeyData.ImplicitTxn,
database: statistics[i].Key.KeyData.Database,
stmtNoConstants: statistics[i].Key.KeyData.Query,
failed: statistics[i].Key.KeyData.Failed,
implicitTxn: statistics[i].Key.KeyData.ImplicitTxn,
database: statistics[i].Key.KeyData.Database,
},
planHash: statistics[i].Key.KeyData.PlanHash,
transactionFingerprintID: statistics[i].Key.KeyData.TransactionFingerprintID,
Expand Down Expand Up @@ -479,7 +479,7 @@ func (s *stmtStats) mergeStatsLocked(statistics *roachpb.CollectedStatementStati
// stat object is returned or not, we always return the correct stmtFingerprintID
// for the given stmt.
func (s *Container) getStatsForStmt(
anonymizedStmt string,
stmtNoConstants string,
implicitTxn bool,
database string,
failed bool,
Expand All @@ -497,10 +497,10 @@ func (s *Container) getStatsForStmt(
// that we use separate buckets for the different situations.
key = stmtKey{
sampledPlanKey: sampledPlanKey{
anonymizedStmt: anonymizedStmt,
failed: failed,
implicitTxn: implicitTxn,
database: database,
stmtNoConstants: stmtNoConstants,
failed: failed,
implicitTxn: implicitTxn,
database: database,
},
planHash: planHash,
transactionFingerprintID: transactionFingerprintID,
Expand Down Expand Up @@ -671,10 +671,10 @@ func (s *Container) MergeApplicationStatementStats(
}
key := stmtKey{
sampledPlanKey: sampledPlanKey{
anonymizedStmt: statistics.Key.Query,
failed: statistics.Key.Failed,
implicitTxn: statistics.Key.ImplicitTxn,
database: statistics.Key.Database,
stmtNoConstants: statistics.Key.Query,
failed: statistics.Key.Failed,
implicitTxn: statistics.Key.ImplicitTxn,
database: statistics.Key.Database,
},
planHash: statistics.Key.PlanHash,
transactionFingerprintID: statistics.Key.TransactionFingerprintID,
Expand Down Expand Up @@ -961,6 +961,6 @@ type transactionCounts struct {

func constructStatementFingerprintIDFromStmtKey(key stmtKey) roachpb.StmtFingerprintID {
return roachpb.ConstructStatementFingerprintID(
key.anonymizedStmt, key.failed, key.implicitTxn, key.database,
key.stmtNoConstants, key.failed, key.implicitTxn, key.database,
)
}
6 changes: 3 additions & 3 deletions pkg/sql/sqlstats/ssmemstorage/ss_mem_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func (s *Container) ShouldSaveLogicalPlanDesc(
fingerprint string, implicitTxn bool, database string,
) bool {
lastSampled := s.getLogicalPlanLastSampled(sampledPlanKey{
anonymizedStmt: fingerprint,
implicitTxn: implicitTxn,
database: database,
stmtNoConstants: fingerprint,
implicitTxn: implicitTxn,
database: database,
})
return s.shouldSaveLogicalPlanDescription(lastSampled)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/sqlstats/ssmemstorage/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s stmtList) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s stmtList) Less(i, j int) bool {
cmp := strings.Compare(s[i].anonymizedStmt, s[j].anonymizedStmt)
cmp := strings.Compare(s[i].stmtNoConstants, s[j].stmtNoConstants)
if cmp == -1 {
return true
}
Expand Down

0 comments on commit c9267e2

Please sign in to comment.