Skip to content

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

Merged
denisra merged 2 commits into
release/2.37from
backport/31765-to-2.37
Nov 24, 2026
Merged

denisra merged 2 commits into
release/2.37from
backport/31765-to-2.37

Conversation

@coder-backporter-app

@coder-backporter-app coder-backporter-app Bot commented Nov 10, 2026 •

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

Resolved the conflicts by hand. I dropped the docs hunk since this branch's Prometheus docs have no example query, and kept only the new TestGetTemplateParameterInsights from querier_test.go. TestGetTemplateParameterInsights and the coderd insights tests pass locally on release/2.37.

The automatic cherry-pick of 3728e7a to release/2.37 had conflicts.
Please cherry-pick manually:

    git cherry-pick -x -m1 3728e7a
@github-actions

Copy link
Copy Markdown
Contributor

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

This PR is targeting the release/2.37 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.

…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).

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

(cherry picked from commit 3728e7a)

The docs hunk is dropped on this branch because its Prometheus
docs have no example query; only the generated metrics table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dylanhuff-at-coder dylanhuff-at-coder changed the title perf: use the build parameter index in GetTemplateParameterInsights (#31765) (conflicts) perf: use the build parameter index in GetTemplateParameterInsights (#31765) Nov 10, 2026
@denisra
denisra merged commit 6db930d into release/2.37 Nov 24, 2026
38 checks passed
@denisra
denisra deleted the backport/31765-to-2.37 branch November 24, 2026 09:18

This branch had an error being deployed

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

Labels

backport/v2.37 Backport PR targeting release/2.37

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants