Skip to content

fix(coderd): optimize template app insights query for speed and decrease intervals #9302

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

Merged
merged 6 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
use microsecond, postgres time granularity
  • Loading branch information
mafredri committed Aug 24, 2023
commit d65295ee61c11b2dfdc7784d72e1c00f727d079a
4 changes: 2 additions & 2 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions coderd/database/queries/insights.sql
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ WITH app_stats_by_user_and_agent AS (
-- for the longer intervals.
CROSS JOIN LATERAL generate_series(
date_trunc('minute', was.session_started_at),
-- Subtract 1ms to avoid creating an extra series.
date_trunc('minute', was.session_ended_at - '1 ms'::interval),
-- Subtract 1 microsecond to avoid creating an extra series.
date_trunc('minute', was.session_ended_at - '1 microsecond'::interval),
'1 minute'::interval
) s(start_time)
WHERE
Expand Down