Skip to content

Commit

Permalink
chore(coderd/database): reduce dbpurge load with smaller batches of a…
Browse files Browse the repository at this point in the history
…gent stats (#13049)
  • Loading branch information
mafredri committed Apr 23, 2024
1 parent 2f7f9d0 commit a69fc65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions coderd/database/queries.sql.go

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

8 changes: 4 additions & 4 deletions coderd/database/queries/workspaceagentstats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ WHERE
template_usage_stats
)
AND created_at < (
-- Delete at most in batches of 3 days (with a batch size of 3 days, we
-- can clear out the previous 6 months of data in ~60 iterations) whilst
-- keeping the DB load relatively low.
-- Delete at most in batches of 4 hours (with this batch size, assuming
-- 1 iteration / 10 minutes, we can clear out the previous 6 months of
-- data in 7.5 days) whilst keeping the DB load low.
SELECT
COALESCE(MIN(created_at) + '3 days'::interval, NOW())
COALESCE(MIN(created_at) + '4 hours'::interval, NOW())
FROM
workspace_agent_stats
);
Expand Down

0 comments on commit a69fc65

Please sign in to comment.