- Notifications
You must be signed in to change notification settings - Fork928
fix(coderd/database): improve perf ofGetTemplateInsightsByInterval
#12773
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
fix(coderd/database): improve perf ofGetTemplateInsightsByInterval
#12773
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This stack of pull requests is managed by Graphite.Learn more about stacking. |
THEN (d::timestamptz + (@interval_days::int || ' day')::interval) | ||
ELSE @end_time::timestamptz | ||
END AS to_ | ||
LEAST( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LEAST
is more performant than case.
@@ -410,6 +413,7 @@ LEFT JOIN | |||
template_usage_stats AS tus | |||
ON | |||
tus.start_time >= ts.from_ | |||
AND tus.start_time < ts.to_ -- End time exclusion criteria optimization for index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Main performance optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nice spotting 👍 👍
@@ -410,6 +413,7 @@ LEFT JOIN | |||
template_usage_stats AS tus | |||
ON | |||
tus.start_time >= ts.from_ | |||
AND tus.start_time < ts.to_ -- End time exclusion criteria optimization for index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nice spotting 👍 👍
Uh oh!
There was an error while loading.Please reload this page.
New:https://explain.dalibo.com/plan/ebf9692d3426f3bd
Old:https://explain.dalibo.com/plan/62eg2ca495g6f2gg
3s -> 61ms.
Refs#12122