Skip to content

Commit

Permalink
Check zero for avgTimePerQuery
Browse files Browse the repository at this point in the history
Signed-off-by: Mingjian Liu <[email protected]>
  • Loading branch information
Mingjian Liu committed Mar 10, 2020
1 parent 124cc43 commit 79197f7
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 79197f7

Please sign in to comment.