Skip to content

Commit c9626be

Browse files
committed
chore(coderd/database): reduce dbpurge load with smaller batches of agent stats
1 parent 81fcdf7 commit c9626be

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

coderd/database/queries.sql.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceagentstats.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ WHERE
8787
template_usage_stats
8888
)
8989
AND created_at < (
90-
-- Delete at most in batches of 3 days (with a batch size of 3 days, we
91-
-- can clear out the previous 6 months of data in ~60 iterations) whilst
92-
-- keeping the DB load relatively low.
90+
-- Delete at most in batches of 4 hours (with this batch size, assuming
91+
-- 1 iteration / 10 minutes, we can clear out the previous 6 months of
92+
-- data in 7.5 days) whilst keeping the DB load low.
9393
SELECT
94-
COALESCE(MIN(created_at) + '3 days'::interval, NOW())
94+
COALESCE(MIN(created_at) + '4 hours'::interval, NOW())
9595
FROM
9696
workspace_agent_stats
9797
);

0 commit comments

Comments
 (0)