Skip to content

bug: GetWorkspaces causes significant DB load #964

@cstyan

Description

@cstyan

For the last 24h this query is the heaviest in terms of DB load as reported by our gcloud SQL query insights.

Image

When we look at our profiling data, the two major call paths for this query are in the entitlements code license.go and the HTTP API path for workspaces which eventually calls GetAuthorizedWorkspaces. The latter we can't address much, that's just ad-hoc organic usage of the platform by actual users. The former however has a nice opporunity for load reduction.

If we look at the Entitlements code in license.go (here) we can see that we call both GetWorkspaces and GetTemplatesWithFilter, filtering on has_external_agent, but then only end up using the results of those queries to get overall counts. We can introduce new queries to only count the # of relevant workspaces and templates, and thus avoid the expensive JOIN's performed (especially in GetWorkspaces) that are used to gather extra fields which are ultimately irrelevant in this code path.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions