René's URL Explorer Experiment


Title: perf(webapp): batch declarative schedule cleanup queries by ericallam · Pull Request #4522 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: perf(webapp): batch declarative schedule cleanup queries by ericallam · Pull Request #4522 · triggerdotdev/trigger.dev

X Title: perf(webapp): batch declarative schedule cleanup queries by ericallam · Pull Request #4522 · triggerdotdev/trigger.dev

Description: Summary syncDeclarativeSchedules runs on every background-worker creation (every deploy, and every file save during trigger dev). It issued one instance-delete per declarative schedule the current worker no longer declares, in a loop, and the overwhelming majority of those deletes matched zero rows. This collapses the loop into at most two set-based statements and skips the instance delete entirely when the current environment owns no instance of the schedule. Why so many, and mostly no-op The loop runs once per entry in missingSchedules, which starts as every DECLARATIVE schedule for the whole project across all its environments (the query filters only by projectId). A schedule leaves that set only when a declared task matches it by taskIdentifier and the schedule already has an instance in the current environment. That last clause is the amplifier. When a task's schedule has no instance in the current environment, the create branch inserts a brand-new TaskSchedule row with an instance for this environment rather than adding an instance to the existing row. So the same scheduled task, once it has run in dev and been deployed to prod, exists as two separate schedule rows: one carrying a dev instance, one carrying a prod instance. On a dev worker sync of that project: the dev-instance row matches the declared task and is removed from the set the prod-instance row has the same taskIdentifier but no dev instance, so it stays in the set and gets deleteMany(taskScheduleId = prodRow, environmentId = dev), which matches zero rows So every declarative task that has been synced in another environment contributes one guaranteed no-op delete per sync, and the count scales with (declarative tasks x environments), plus any leftover rows from renamed or removed tasks. A project does not need to have dropped a schedule to generate these; it just needs the same declarative tasks present in more than one environment, which is the normal develop-in-dev, deploy-to-prod case. Fix The candidate schedules are already loaded with their instances, so the branch is decided in memory: schedules with no instances (or only current-environment instances) are removed in a single taskSchedule.deleteMany schedules that still have another environment's instance have only the current environment's instance detached, in a single taskScheduleInstance.deleteMany, and only when such an instance actually exists Behavior is unchanged (cascade delete still removes the instances of a deleted schedule); the difference is statement count. A zero-row delete writes no WAL and creates no dead tuples, so the removed work was pure query and commit overhead. Verified with a testcontainer test (red before, green after) counting the emitted deletes across the no-op, batched-detach, and schedule-delete cases, and end to end through trigger dev: three declarative schedules created, surviving a re-sync, then two removed in a single batched delete with the third preserved.

Open Graph Description: Summary syncDeclarativeSchedules runs on every background-worker creation (every deploy, and every file save during trigger dev). It issued one instance-delete per declarative schedule the current ...

X Description: Summary syncDeclarativeSchedules runs on every background-worker creation (every deploy, and every file save during trigger dev). It issued one instance-delete per declarative schedule the current ...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/4522

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6b5ffaf8-b578-f8f2-dfdf-6f04cf7b33c0
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB662:1F5CA2:6E971E:A2D28B:6AFAF45D
html-safe-noncedc550bc1ce2c42e6bc70eebc8464d331bf0249fc961a7b233759206b896c0124
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjYyOjFGNUNBMjo2RTk3MUU6QTJEMjhCOjZBRkFGNDVEIiwidmlzaXRvcl9pZCI6IjkwMzkzNDY1ODQyMzUyMDk4MjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf81dadb6109607910aa2c6e8b0066f0ce94b101ddcc9cb70eae4a6929ab0316d
hovercard-subject-tagpull_request:4221806893
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/4522/files
twitter:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
og:image:altSummary syncDeclarativeSchedules runs on every background-worker creation (every deploy, and every file save during trigger dev). It issued one instance-delete per declarative schedule the current ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea85e96a83bed7871993e6b1ffda24105928eee17
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/4522/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4522%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4522%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests67 (67)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
ericallamhttps://github.com/ericallam
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
feature/tri-13016-syncdeclarativeschedules-issues-970-mostly-no-op-deletessechttps://github.com/triggerdotdev/trigger.dev/tree/feature/tri-13016-syncdeclarativeschedules-issues-970-mostly-no-op-deletessec
Conversation 15 https://github.com/triggerdotdev/trigger.dev/pull/4522
Commits 1 https://github.com/triggerdotdev/trigger.dev/pull/4522/commits
Checks 66 https://github.com/triggerdotdev/trigger.dev/pull/4522/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4522/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
perf(webapp): batch declarative schedule cleanup queries https://github.com/triggerdotdev/trigger.dev/pull/4522/files#top
Show all changes 1 commit https://github.com/triggerdotdev/trigger.dev/pull/4522/files
8030e5f perf(webapp): batch declarative schedule cleanup queries ericallam Aug 6, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4522/commits/8030e5f9ce33ff2867b3ba913f09d0ef32b9319f
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4522/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
batch-declarative-schedule-cleanup.md https://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-65aeed89df551294ed2562b0f042732d0104881dc882b9999b0c5aafcaa7c28d
createBackgroundWorker.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-4f6cfdca149e5081bfdd486395d42c6d7e2a1d40a2bdf3e1c2e690d5c03b7efa
syncDeclarativeSchedules.test.ts https://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-8d9b45367fe54632aa2c29bede520d6f8b579eb7ecc7732ba77de2cf150ab1c7
.server-changes/batch-declarative-schedule-cleanup.mdhttps://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-65aeed89df551294ed2562b0f042732d0104881dc882b9999b0c5aafcaa7c28d
View file https://github.com/triggerdotdev/trigger.dev/blob/8030e5f9ce33ff2867b3ba913f09d0ef32b9319f/.server-changes/batch-declarative-schedule-cleanup.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4522/{{ revealButtonHref }}
apps/webapp/app/v3/services/createBackgroundWorker.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-4f6cfdca149e5081bfdd486395d42c6d7e2a1d40a2bdf3e1c2e690d5c03b7efa
View file https://github.com/triggerdotdev/trigger.dev/blob/8030e5f9ce33ff2867b3ba913f09d0ef32b9319f/apps/webapp/app/v3/services/createBackgroundWorker.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4522/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-4f6cfdca149e5081bfdd486395d42c6d7e2a1d40a2bdf3e1c2e690d5c03b7efa
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
https://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-4f6cfdca149e5081bfdd486395d42c6d7e2a1d40a2bdf3e1c2e690d5c03b7efa
apps/webapp/test/syncDeclarativeSchedules.test.tshttps://github.com/triggerdotdev/trigger.dev/pull/4522/files#diff-8d9b45367fe54632aa2c29bede520d6f8b579eb7ecc7732ba77de2cf150ab1c7
View file https://github.com/triggerdotdev/trigger.dev/blob/8030e5f9ce33ff2867b3ba913f09d0ef32b9319f/apps/webapp/test/syncDeclarativeSchedules.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4522/{{ revealButtonHref }}
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4522/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.