fix: make sure we use partial index when creating scheduled and cron refs#4260
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes workflow version lookup used when creating cron and scheduled trigger refs so queries filter to non-deleted workflow versions, allowing Postgres to use the intended partial index (idx_workflow_version_workflow_id_order) and avoid high CPU on large tables.
Changes:
- Add
AND "deletedAt" IS NULLto thelatest_versionCTE used for cron trigger ref creation. - Add
AND "deletedAt" IS NULLto thelatest_versionCTE used for scheduled trigger ref creation. - Regenerate/update the corresponding
sqlc-generated.sql.goquery constants.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/repository/sqlcv1/workflows.sql | Adds "deletedAt" IS NULL filter to latest workflow version selection for cron refs. |
| pkg/repository/sqlcv1/workflows.sql.go | sqlc-generated output updated to match the cron ref query change. |
| pkg/repository/sqlcv1/workflow_schedules.sql | Adds "deletedAt" IS NULL filter to latest workflow version selection for scheduled refs. |
| pkg/repository/sqlcv1/workflow_schedules.sql.go | sqlc-generated output updated to match the scheduled ref query change. |
Files not reviewed (2)
- pkg/repository/sqlcv1/workflow_schedules.sql.go: Generated file
- pkg/repository/sqlcv1/workflows.sql.go: Generated file
grutt
approved these changes
Jun 23, 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
When creating scheduled and cron refs we were not properly filtering for latest workflow version and hence not using the desired partial index
idx_workflow_version_workflow_id_orderwhich can lead to high CPU when there are millions of rows in the respective tables.Type of change
What's Changed
deletedAt IS NULLto existing SQL CTEs when filtering for latest workflow versions.Checklist
Changes have been:
🤖 AI Disclosure