Skip to content

Commit

Permalink
Merge pull request #5904 from bumbing/upstream3
Browse files Browse the repository at this point in the history
Check zero for avgTimePerQuery
  • Loading branch information
sougou authored Apr 23, 2020
2 parents bf05e95 + 79197f7 commit 5c7a0ca
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions go/vt/vtgate/executor_scatter_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ func (e *Executor) gatherScatterStats() (statsResults, error) {
resultItems := make([]*statsResultItem, len(plans))
for i, plan := range plans {
route := routes[i]
var avgTimePerQuery int64
if plan.ExecCount != 0 {
avgTimePerQuery = plan.ExecTime.Nanoseconds() / int64(plan.ExecCount)
}
resultItems[i] = &statsResultItem{
Query: plan.Original,
AvgTimePerQuery: time.Duration(plan.ExecTime.Nanoseconds() / int64(plan.ExecCount)),
PercentTimeOfReads: float64(100 * plan.ExecTime / readOnlyTime),
PercentTimeOfScatters: float64(100 * plan.ExecTime / scatterExecTime),
PercentCountOfReads: float64(100 * plan.ExecCount / readOnlyCount),
PercentCountOfScatters: float64(100 * plan.ExecCount / scatterCount),
AvgTimePerQuery: time.Duration(avgTimePerQuery),
PercentTimeOfReads: 100 * float64(plan.ExecTime) / float64(readOnlyTime),
PercentTimeOfScatters: 100 * float64(plan.ExecTime) / float64(scatterExecTime),
PercentCountOfReads: 100 * float64(plan.ExecCount) / float64(readOnlyCount),
PercentCountOfScatters: 100 * float64(plan.ExecCount) / float64(scatterCount),
From: route.Keyspace.Name + "." + route.TableName,
Count: plan.ExecCount,
}
Expand Down

0 comments on commit 5c7a0ca

Please sign in to comment.