Skip to content

Conversation

cstyan
Copy link
Contributor

@cstyan cstyan commented Aug 29, 2025

This PR should resolve coder/internal#719 by limiting the workspace_builds rows selected by the query to the most recent 100 builds of a template, as opposed to all builds in the last 30d. For our own internal templates with the most builds (1700-2000 in a 30d period) this should cut the query execution time by about 80%.

Unless we have some restriction on keeping the 30d period, contract related or otherwise, this seems like a safe change to make. In addition to the execution speed improvements it also means the memory for the query is bounded as well.

If we want to keep a 30d time period for the avg build time value I think it's worth exploring a purpose built solution such as histogram structures where the build times could be bucketized by template ID as they're observed.

@cstyan cstyan requested a review from deansheather August 29, 2025 18:22
Copy link

github-actions bot commented Aug 29, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

builds of a template as opposed to all builds in the last 30d

Signed-off-by: Callum Styan <callumstyan@gmail.com>
@cstyan cstyan force-pushed the callum/template-build-time-query branch from 47305c3 to cd26f75 Compare August 29, 2025 19:38
Signed-off-by: Callum Styan <callumstyan@gmail.com>
@cstyan cstyan merged commit 4fab14b into main Sep 1, 2025
49 of 53 checks passed
@cstyan cstyan deleted the callum/template-build-time-query branch September 1, 2025 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: GetTemplateAverageBuildTime creates lots of DB load
2 participants