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

Check zero for avgTimePerQuery #5904

Merged
merged 1 commit into from
Apr 23, 2020
Merged

Conversation

mingjianliu
Copy link

Created a simple fix as @dweitzman suggested from #5895

Signed-off-by: Mingjian Liu mingjianliu@pinterest.com

@mingjianliu mingjianliu requested a review from sougou as a code owner March 8, 2020 05:12
resultItems[i] = &statsResultItem{
Query: plan.Original,
AvgTimePerQuery: time.Duration(plan.ExecTime.Nanoseconds() / int64(plan.ExecCount)),
AvgTimePerQuery: time.Duration(avgTimePerQuery),
PercentTimeOfReads: float64(100 * plan.ExecTime / readOnlyTime),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still need to convert all these integral denominators to floats to prevent divide-by-zero panic()s, as per the comment in the closed PR

Creating new PRs for each round of code review makes it trickier for people to keep track of the conversation and previous comments. In case you weren't aware, force-pushing to your existing branch on github will update an existing PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, am kind of new to use Github system. Messed up a bit so created a newer branch. Let me update the code according to comment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cast the dominators to float64

Signed-off-by: Mingjian Liu <mingjianliu@pinterest.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants