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

sql: fix inflated "overhead" in statement timings #53846

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/sql/executor_statement_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ type phaseTimes [sessionNumPhases]time.Time
// getServiceLatency returns the time between a query being received and the end
// of run.
func (p *phaseTimes) getServiceLatency() time.Duration {
return p[plannerEndExecStmt].Sub(p[sessionQueryReceived])
// To have an accurate representation of how long it took to service this
// single query, we ignore the time between when parsing ends and planning
// begins. This avoids the latency being inflated in a few different cases:
// when there are internal transaction retries, and when multiple statements
// are submitted together, e.g. "SELECT 1; SELECT 2".
parseLatency := p[sessionEndParse].Sub(p[sessionQueryReceived])
planAndExecuteLatency := p[plannerEndExecStmt].Sub(p[plannerStartLogicalPlan])
return parseLatency + planAndExecuteLatency
}

// getRunLatency returns the time between a query execution starting and ending.
Expand Down