mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-19 18:34:59 +00:00
PMM-12468 Plan summary, COLLSCAN.
This commit is contained in:
@@ -78,6 +78,7 @@ type SystemProfile struct {
|
|||||||
Ns string `bson:"ns"`
|
Ns string `bson:"ns"`
|
||||||
NumYield int `bson:"numYield"`
|
NumYield int `bson:"numYield"`
|
||||||
Op string `bson:"op"`
|
Op string `bson:"op"`
|
||||||
|
PlanSummary string `bson:"planSummary"`
|
||||||
Protocol string `bson:"protocol"`
|
Protocol string `bson:"protocol"`
|
||||||
Query bson.D `bson:"query"`
|
Query bson.D `bson:"query"`
|
||||||
UpdateObj bson.D `bson:"updateobj"`
|
UpdateObj bson.D `bson:"updateobj"`
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,6 +14,11 @@ import (
|
|||||||
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
"github.com/percona/percona-toolkit/src/go/mongolib/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
planSummaryCollScan = "COLLSCAN"
|
||||||
|
planSummaryIXScan = "IXSCAN"
|
||||||
|
)
|
||||||
|
|
||||||
type StatsError struct {
|
type StatsError struct {
|
||||||
error
|
error
|
||||||
}
|
}
|
||||||
@@ -86,6 +92,7 @@ func (s *Stats) Add(doc proto.SystemProfile) error {
|
|||||||
Namespace: fp.Namespace,
|
Namespace: fp.Namespace,
|
||||||
TableScan: false,
|
TableScan: false,
|
||||||
Query: string(queryBson),
|
Query: string(queryBson),
|
||||||
|
PlanSummary: doc.PlanSummary,
|
||||||
}
|
}
|
||||||
s.setQueryInfoAndCounters(key, qiac)
|
s.setQueryInfoAndCounters(key, qiac)
|
||||||
}
|
}
|
||||||
@@ -93,6 +100,14 @@ func (s *Stats) Add(doc proto.SystemProfile) error {
|
|||||||
// docsExamined is renamed from nscannedObjects in 3.2.0.
|
// docsExamined is renamed from nscannedObjects in 3.2.0.
|
||||||
// https://docs.mongodb.com/manual/reference/database-profiler/#system.profile.docsExamined
|
// https://docs.mongodb.com/manual/reference/database-profiler/#system.profile.docsExamined
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
qiac.PlanSummary = doc.PlanSummary
|
||||||
|
if qiac.PlanSummary == planSummaryCollScan {
|
||||||
|
qiac.CollScanCount++
|
||||||
|
qiac.CollScanSum += int64(doc.Millis)
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(qiac.PlanSummary, planSummaryIXScan) {
|
||||||
|
qiac.PlanSummary = planSummaryIXScan
|
||||||
|
}
|
||||||
if doc.NscannedObjects > 0 {
|
if doc.NscannedObjects > 0 {
|
||||||
qiac.NScanned = append(qiac.NScanned, float64(doc.NscannedObjects))
|
qiac.NScanned = append(qiac.NScanned, float64(doc.NscannedObjects))
|
||||||
} else {
|
} else {
|
||||||
@@ -188,6 +203,10 @@ type QueryInfoAndCounters struct {
|
|||||||
NScanned []float64
|
NScanned []float64
|
||||||
QueryTime []float64 // in milliseconds
|
QueryTime []float64 // in milliseconds
|
||||||
ResponseLength []float64
|
ResponseLength []float64
|
||||||
|
|
||||||
|
PlanSummary string
|
||||||
|
CollScanCount int
|
||||||
|
CollScanSum int64 // in milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
// times is an array of time.Time that implements the Sorter interface
|
// times is an array of time.Time that implements the Sorter interface
|
||||||
@@ -238,6 +257,10 @@ type QueryStats struct {
|
|||||||
ResponseLength Statistics
|
ResponseLength Statistics
|
||||||
Returned Statistics
|
Returned Statistics
|
||||||
Scanned Statistics
|
Scanned Statistics
|
||||||
|
|
||||||
|
PlanSummary string
|
||||||
|
CollScanCount int
|
||||||
|
CollScanSum int64 // in milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
type Statistics struct {
|
type Statistics struct {
|
||||||
@@ -267,6 +290,9 @@ func countersToStats(query QueryInfoAndCounters, uptime int64, tc totalCounters)
|
|||||||
LastSeen: query.LastSeen,
|
LastSeen: query.LastSeen,
|
||||||
Namespace: query.Namespace,
|
Namespace: query.Namespace,
|
||||||
QPS: float64(query.Count) / float64(uptime),
|
QPS: float64(query.Count) / float64(uptime),
|
||||||
|
PlanSummary: query.PlanSummary,
|
||||||
|
CollScanCount: query.CollScanCount,
|
||||||
|
CollScanSum: query.CollScanSum,
|
||||||
}
|
}
|
||||||
if tc.Scanned > 0 {
|
if tc.Scanned > 0 {
|
||||||
queryStats.Scanned.Pct = queryStats.Scanned.Total * 100 / tc.Scanned
|
queryStats.Scanned.Pct = queryStats.Scanned.Total * 100 / tc.Scanned
|
||||||
|
Reference in New Issue
Block a user