Skip to content

Commit

Permalink
PMM-9288 Remove nScanned completely.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Feb 19, 2025
1 parent 330ca87 commit 30b8f42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
12 changes: 4 additions & 8 deletions src/go/mongolib/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func (g GroupKey) String() string {

type totalCounters struct {
Count int
Scanned float64
Returned float64
QueryTime float64
Bytes float64
Expand Down Expand Up @@ -298,7 +297,6 @@ type QueryStats struct {
ResponseLengthCount int
ResponseLength Statistics
Returned Statistics
Scanned Statistics

PlanSummary string
CollScanCount int
Expand Down Expand Up @@ -376,9 +374,6 @@ func countersToStats(query QueryInfoAndCounters, uptime int64, tc totalCounters)
StorageTimeReadingMicrosCount: len(query.StorageTimeReadingMicros),
StorageTimeReadingMicros: calcStats(query.StorageTimeReadingMicros),
}
if tc.Scanned > 0 {
queryStats.Scanned.Pct = queryStats.Scanned.Total * 100 / tc.Scanned
}
if tc.Returned > 0 {
queryStats.Returned.Pct = queryStats.Returned.Total * 100 / tc.Returned
}
Expand All @@ -388,9 +383,6 @@ func countersToStats(query QueryInfoAndCounters, uptime int64, tc totalCounters)
if tc.Bytes > 0 {
queryStats.ResponseLength.Pct = queryStats.ResponseLength.Total * 100 / tc.Bytes
}
if queryStats.Returned.Total > 0 {
queryStats.Ratio = queryStats.Scanned.Total / queryStats.Returned.Total
}
if tc.DocsExamined > 0 {
queryStats.DocsExamined.Pct = queryStats.DocsExamined.Total * 100 / tc.DocsExamined
}
Expand Down Expand Up @@ -460,6 +452,10 @@ func calcTotalCounters(queries []QueryInfoAndCounters) totalCounters {
}

func calcStats(samples []float64) Statistics {
if len(samples) == 0 {
return Statistics{}
}

var s Statistics
s.Total, _ = stats.Sum(samples)
s.Min, _ = stats.Min(samples)
Expand Down
12 changes: 6 additions & 6 deletions src/go/pt-mongodb-query-digest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,23 +497,23 @@ func sortQueries(queries []stats.QueryStats, orderby []string) []stats.QueryStat
}

//
case "docs-scanned":
case "docs-examined":
f = func(c1, c2 *stats.QueryStats) bool {
return c1.Scanned.Max < c2.Scanned.Max
return c1.DocsExamined.Max < c2.DocsExamined.Max
}
case "-docs-scanned":
case "-docs-examined":
f = func(c1, c2 *stats.QueryStats) bool {
return c1.Scanned.Max > c2.Scanned.Max
return c1.DocsExamined.Max > c2.DocsExamined.Max
}

//
case "docs-returned":
f = func(c1, c2 *stats.QueryStats) bool {
return c1.Returned.Max < c2.Scanned.Max
return c1.Returned.Max < c2.DocsExamined.Max
}
case "-docs-returned":
f = func(c1, c2 *stats.QueryStats) bool {
return c1.Returned.Max > c2.Scanned.Max
return c1.Returned.Max > c2.DocsExamined.Max
}
}
// count,query-time,docs-scanned, docs-returned. - in front of the field name denotes reverse order.")
Expand Down

0 comments on commit 30b8f42

Please sign in to comment.