Skip to content

Fix: improve performance of cron schedule polling query#3754

Merged
mrkaye97 merged 4 commits intomainfrom
mk/improve-cron-schedules-query
Apr 28, 2026
Merged

Fix: improve performance of cron schedule polling query#3754
mrkaye97 merged 4 commits intomainfrom
mk/improve-cron-schedules-query

Conversation

@mrkaye97
Copy link
Copy Markdown
Contributor

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 WorkflowTriggers bridge table

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Copilot AI review requested due to automatic review settings April 27, 2026 19:07
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hatchet-docs Ready Ready Preview, Comment Apr 27, 2026 9:26pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to DISTINCT 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.

Comment thread pkg/repository/sqlcv1/ticker.sql
Comment thread pkg/repository/sqlcv1/ticker.sql.go
Comment thread cmd/hatchet-migrate/migrate/migrations/20260427190534_v1_0_102.sql
@mrkaye97 mrkaye97 merged commit c4b30a6 into main Apr 28, 2026
39 checks passed
@mrkaye97 mrkaye97 deleted the mk/improve-cron-schedules-query branch April 28, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants