Fix: improve performance of cron schedule polling query#3754
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
grutt
approved these changes
Apr 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Improves performance of cron schedule polling by reshaping the PollCronSchedules query to better constrain workflow-version selection and by adding an index intended to support the polling join path.
Changes:
- Reorders/rewrites CTEs in
PollCronSchedules, materializing the eligible cron set and switching latest-version selection toDISTINCT ON (...) ORDER BY ... DESC. - Updates the join condition to validate that cron triggers point at the latest workflow version via
workflowVersionId. - Adds a concurrent index on
"WorkflowTriggers"to reduce lookup cost during polling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/repository/sqlcv1/ticker.sql.go | Updates generated query for cron polling (materialized eligible CTE + latest-version selection by DISTINCT ON). |
| pkg/repository/sqlcv1/ticker.sql | Updates source SQL for cron polling with the same CTE/join strategy. |
| cmd/hatchet-migrate/migrate/migrations/20260427190534_v1_0_102.sql | Adds a concurrent index on "WorkflowTriggers" to support cron polling lookups. |
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
Improving the performance of the cron schedule polling query using the materialized cte trick to force a nested loop, and adding a covering index on some columns in the
WorkflowTriggersbridge tableType of change