Fix: Improve performance of status metrics query#3800
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Improves performance of the GetTenantStatusMetrics OLAP query (used by GET /api/v1/stable/tenants/:tenant/task-metrics) by pushing tenant/time/workflow filters down into the task_external_ids CTE so Postgres can better prune partitions and use existing indexes.
Changes:
- Added
tenant_id,inserted_at(createdAfter/createdBefore), andworkflow_idfilters to thetask_external_idsCTE inGetTenantStatusMetrics. - Regenerated the sqlc output to reflect the updated SQL.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/repository/sqlcv1/olap.sql | Pushes existing filters into the task_external_ids CTE to reduce scanned partitions/rows for status metrics. |
| pkg/repository/sqlcv1/olap.sql.go | Regenerated sqlc output reflecting the updated query definition. |
grutt
reviewed
May 5, 2026
| ) | ||
| ) | ||
| AND tenant_id = @tenantId::UUID | ||
| AND inserted_at >= @createdAfter::TIMESTAMPTZ |
Contributor
Author
There was a problem hiding this comment.
don't think so, why would it be?
Contributor
There was a problem hiding this comment.
my fault, missed that we already had created after later in the query
grutt
approved these changes
May 5, 2026
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.
Description
Fixes #3790
Adds some additional filters to the runs CTE to prune partitions and make use of the tenant index, which should hopefully improve performance a lot
Type of change