Repository navigation
Conversation
This was referenced Nov 2, 2026
kylecarbs
marked this pull request as ready for review
November 3, 2026 22:11
The filter, sort, and count CTE read the wide workspaces_expanded view, including per-row ACL subqueries, for every matching workspace. Filter and sort on the base table and join workspaces_expanded for the returned page only. The template filter uses ANY(ARRAY(...)) so the planner can use workspace_template_id_idx. GetDeploymentWorkspaceStats counts in one pass with FILTER instead of scanning a materialized CTE five times. Generated by Coder Agents.
kylecarbs
force-pushed
the
perf/db-workspaces-list
branch
from
November 9, 2026 21:28
2215316 to
b42a426
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GetWorkspacesandGetAuthorizedWorkspacesfiltered, sorted, and counted on the wideworkspaces_expandedview, including its per-row ACL subqueries, for every matching workspace (about 189k rows here), only to return 25. The inflated cost estimate also triggered about 0.8 s of JIT compilation.The filter, sort, and count now run on the base
workspacestable plususers.username, and a newfiltered_workspaces_pageCTE joinsworkspaces_expandedfor the returned page only. Filters, the RBAC placeholder, and output columns are unchanged, as are the generated row type and the scan inmodelqueries.go. The template filter uses= ANY(ARRAY(SELECT ...))so the planner usesworkspace_template_id_idxinstead of assuming 50% selectivity.GetDeploymentWorkspaceStatscounts in one pass withFILTERinstead of scanning a materialized CTE five times.template:X(6k workspaces)status:runningdeleted:trueGetDeploymentWorkspaceStatsOwner filters were already a few ms and are unchanged.
Review focus: this is the most-used list query.
Depends on #31626.
Decision log
status:runninglists is the latest build and job lookup for every visible workspace (about 189k index pairs, not parallelized), plus sorting by lowercased username and name.status:runningfrom 3183 to 543 ms, and deployment stats from 1760 to 86 ms. It touches the provisioner job lifecycle, so it should be its own change.Generated by Coder Agents on behalf of @kylecarbs.