Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: rename anonymizedStmt in sqlstats pkg to stmtNoConstants #83428

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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