Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8442baa

Browse files
committed
feat(coderd/database): keep only 1 day ofworkspace_agent_stats after rollup
1 parent71cd6ff commit8442baa

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

‎coderd/database/queries.sql.go

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/workspaceagentstats.sql

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,26 @@ ORDER BY
9090
dateASC;
9191

9292
-- name: DeleteOldWorkspaceAgentStats :exec
93-
DELETEFROM workspace_agent_statsWHERE created_at< NOW()- INTERVAL'180 days';
93+
DELETEFROM
94+
workspace_agent_stats
95+
WHERE
96+
created_at< (
97+
SELECT
98+
COALESCE(
99+
-- When generating initial template usage stats, all the
100+
-- raw agent stats are needed, after that only ~30 mins
101+
-- from last rollup is needed. Deployment stats seem to
102+
-- use between 15 mins and 1 hour of data. We keep a
103+
-- little bit more (1 day) just in case.
104+
MAX(start_time)-'1 days'::interval,
105+
-- Fall back to 180 days ago if there are no template
106+
-- usage stats so that we don't delete the data before
107+
-- it's rolled up.
108+
NOW()-'180 days'::interval
109+
)
110+
FROM
111+
template_usage_stats
112+
);
94113

95114
-- name: GetDeploymentWorkspaceAgentStats :one
96115
WITH agent_statsAS (

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp