Skip to content

perf: use the build parameter index in GetTemplateParameterInsights (#31765) - #32008

Merged
denisra merged 1 commit into
release/2.39from
backport/31765-to-2.39
Nov 24, 2026
Merged

denisra merged 1 commit into
release/2.39from
backport/31765-to-2.39

Conversation

@coder-backporter-app

Copy link
Copy Markdown

Backport of #31765

Original PR: #31765 — perf: use the build parameter index in GetTemplateParameterInsights
Merge commit: 3728e7a
Requested by: @dylanhuff-at-coder

…31765)

Speeds up `GetTemplateParameterInsights`, which the insights collector
runs every 5 minutes on every replica. The `@>` array join could only
hash on `name`, so every run scanned all of
`workspace_build_parameters`. Unnesting the build IDs and joining on
`(workspace_build_id, name)` lets the existing unique index serve it,
and the results don't change since each build ID shows up at most once
per group.

On 8.4M synthetic build parameters the collector's 5 minute window went
from 5,193 ms to about 31 ms. `TestGetTemplateParameterInsights` is new
and passes on both the old and new SQL. This also fixes the Prometheus
docs example, which summed per-replica copies of the same metric.

I split the `workspace_app_stats` index into #31766 so this one has no
migration and can be backported to 2.34 through 2.39 (2.34 to 2.38
without the docs hunk).

The pre-push hook skipped tests on this push because of a stale
`origin/main` in my checkout. An earlier full run only failed in
`agent/` and `site/`.

Part of [CORE-439](https://linear.app/codercom/issue/CORE-439).

(cherry picked from commit 3728e7a)
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @coder-backporter-app[bot]!

This PR is targeting the release/2.39 release branch, but its title does not start with fix: or fix(scope):.

Only bug fixes should be cherry-picked to release branches. If this is a bug fix, please update the PR title to match the conventional commit format:

fix: description of the bug fix
fix(scope): description of the bug fix

If this is not a bug fix, it likely should not target a release branch.

@denisra
denisra merged commit 21c448e into release/2.39 Nov 24, 2026
62 of 63 checks passed
@denisra
denisra deleted the backport/31765-to-2.39 branch November 24, 2026 09:16

This branch had an error being deployed

1 failed deployment
docs-preview — bd959704 Deployed Nov 24, 2026 by denisra via cleanup #389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.39 Backport PR targeting release/2.39

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants