chore(coderd/database): reduce dbpurge load with smaller batches of agent stats (#13049)

This commit is contained in:
Mathias Fredriksson 2024-04-23 15:01:56 +03:00 committed by GitHub
parent 2f7f9d022a
commit a69fc657f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -10132,11 +10132,11 @@ WHERE
template_usage_stats template_usage_stats
) )
AND created_at < ( AND created_at < (
-- Delete at most in batches of 3 days (with a batch size of 3 days, we -- Delete at most in batches of 4 hours (with this batch size, assuming
-- can clear out the previous 6 months of data in ~60 iterations) whilst -- 1 iteration / 10 minutes, we can clear out the previous 6 months of
-- keeping the DB load relatively low. -- data in 7.5 days) whilst keeping the DB load low.
SELECT SELECT
COALESCE(MIN(created_at) + '3 days'::interval, NOW()) COALESCE(MIN(created_at) + '4 hours'::interval, NOW())
FROM FROM
workspace_agent_stats workspace_agent_stats
) )

View File

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