René's URL Explorer Experiment


Title: perf(webapp,database): index the newest-task-version lookup by ericallam · Pull Request #4518 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: perf(webapp,database): index the newest-task-version lookup by ericallam · Pull Request #4518 · triggerdotdev/trigger.dev

X Title: perf(webapp,database): index the newest-task-version lookup by ericallam · Pull Request #4518 · triggerdotdev/trigger.dev

Description: Implementing PlanetScale Insights improvement. Summary Validating a schedule (creating or updating one through the API or the dashboard, and deploying a project that declares schedules) looks up the newest version of a task by slug. That lookup reads every version of the task and sorts them to return one. A project gains a row per task on every deploy, so the work grows with the project's age: the oldest projects pay the most, and dev-mode redeploys make it worse. This was picked because it was the largest single consumer of database time on the schedules path, and the fix is a sort key with no index behind it. Fix BackgroundWorkerTask is indexed on (projectId, slug), which serves the equality but not the ORDER BY createdAt DESC. Postgres seeks the index, then bitmap-scans and top-N sorts the whole group to produce a single row. Adding createdAt to the index lets it scan backward and stop at the first row. The same call site also selected all 21 columns, including five JSON blobs, to read one field (triggerSource), so it now selects that field alone. Benchmark Local Postgres 17, 997,000 seeded rows / 748 MB, group sizes chosen to match the distribution seen in production. Group size Before After 15,000 versions of one task 11.118 ms, 1,510 buffers, 15,000 rows scanned 0.027 ms, 4 buffers, 1 row 2,000 versions of one task 2.081 ms, 1,455 buffers, 2,000 rows scanned 0.022 ms, 4 buffers, 1 row before: Limit -> Sort (top-N heapsort) -> Bitmap Heap Scan after: Limit -> Index Scan Backward using BackgroundWorkerTask_projectId_slug_createdAt_idx An ascending index scanned backward is enough here, so no descending index is needed. Impact and risk Real-world gain lands between the two rows above and scales with how many deploys a project has accumulated. Projects with few deploys will see little change, since there is barely anything to sort. The new index costs noticeably more than the existing two-column one: 43 MB against 7.3 MB on the benchmark rig. Adding createdAt makes every key unique, which defeats btree deduplication, so this is a real disk and write cost rather than a rounding error. Writes to this table happen at deploy time, not on the run path, so the write amplification is acceptable. The existing (projectId, slug) index is now a redundant prefix and could be dropped, but this PR keeps it so index usage can be observed before removing it. Behavior is unchanged: same predicate, same ordering, same row returned. The narrowed select is the only code change, and the field it keeps is the only one the caller read. Deploy note: the migration is 20260806100000_add_background_worker_task_project_id_slug_created_at_index and uses CREATE INDEX CONCURRENTLY IF NOT EXISTS, so it can be pre-applied by hand before the deploy.

Open Graph Description: Implementing PlanetScale Insights improvement. Summary Validating a schedule (creating or updating one through the API or the dashboard, and deploying a project that declares schedules) looks up th...

X Description: Implementing PlanetScale Insights improvement. Summary Validating a schedule (creating or updating one through the API or the dashboard, and deploying a project that declares schedules) looks up th...

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

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:25b96834-b48e-3329-a201-396dbbf3f168
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9B82:1CA15F:43122D8:5ACE736:6AFAF696
html-safe-nonce91780afec2dd200502e42f093a25a3cf4c6068a37c60f286dd8797fac56b9b65
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjgyOjFDQTE1Rjo0MzEyMkQ4OjVBQ0U3MzY6NkFGQUY2OTYiLCJ2aXNpdG9yX2lkIjoiMjEwMjMyNzYwOTE4NTIwMzg2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4603899a06891b1b1bdbeb7f8ef4320cefc55eb4e7dc668cd13cfb607f0d6b4c
hovercard-subject-tagpull_request:4219939668
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/4518/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:altImplementing PlanetScale Insights improvement. Summary Validating a schedule (creating or updating one through the API or the dashboard, and deploying a project that declares schedules) looks up th...
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/4518/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4518%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%2F4518%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/4518/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4518/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4518/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-13013-index-backgroundworkertask-on-projectid-slug-createdat-26https://github.com/triggerdotdev/trigger.dev/tree/feature/tri-13013-index-backgroundworkertask-on-projectid-slug-createdat-26
Conversation 5 https://github.com/triggerdotdev/trigger.dev/pull/4518
Commits 1 https://github.com/triggerdotdev/trigger.dev/pull/4518/commits
Checks 49 https://github.com/triggerdotdev/trigger.dev/pull/4518/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4518/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4518/files
perf(webapp,database): index the newest-task-version lookup https://github.com/triggerdotdev/trigger.dev/pull/4518/files#top
Show all changes 1 commit https://github.com/triggerdotdev/trigger.dev/pull/4518/files
f7ac0f4 perf(webapp,database): index the newest-task-version lookup ericallam Aug 6, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4518/commits/f7ac0f440af825b099d58faf659db6b02dd76273
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4518/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4518/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4518/files
faster-schedule-validation-lookup.md https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-48f56402caff692bcef7d06c100465665f8c052b273899423f06f4e65bb9bcc7
checkSchedule.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-d09d176be0e62f7550b0a1fa3d70c9550990df9f485e0dc86ef44c241abf9641
migration.sql https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-728feebd0d65ced08bf329799580c3bece0acd3e8fc7b4fd20bb6e6f4b8f4774
schema.prisma https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
.server-changes/faster-schedule-validation-lookup.mdhttps://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-48f56402caff692bcef7d06c100465665f8c052b273899423f06f4e65bb9bcc7
View file https://github.com/triggerdotdev/trigger.dev/blob/f7ac0f440af825b099d58faf659db6b02dd76273/.server-changes/faster-schedule-validation-lookup.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4518/{{ revealButtonHref }}
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4518/files
apps/webapp/app/v3/services/checkSchedule.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-d09d176be0e62f7550b0a1fa3d70c9550990df9f485e0dc86ef44c241abf9641
View file https://github.com/triggerdotdev/trigger.dev/blob/f7ac0f440af825b099d58faf659db6b02dd76273/apps/webapp/app/v3/services/checkSchedule.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4518/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-d09d176be0e62f7550b0a1fa3d70c9550990df9f485e0dc86ef44c241abf9641
https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-d09d176be0e62f7550b0a1fa3d70c9550990df9f485e0dc86ef44c241abf9641
.../20260806100000_add_background_worker_task_project_id_slug_created_at_index/migration.sqlhttps://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-728feebd0d65ced08bf329799580c3bece0acd3e8fc7b4fd20bb6e6f4b8f4774
View file https://github.com/triggerdotdev/trigger.dev/blob/f7ac0f440af825b099d58faf659db6b02dd76273/internal-packages/database/prisma/migrations/20260806100000_add_background_worker_task_project_id_slug_created_at_index/migration.sql
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4518/{{ revealButtonHref }}
internal-packages/database/prisma/schema.prismahttps://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
View file https://github.com/triggerdotdev/trigger.dev/blob/f7ac0f440af825b099d58faf659db6b02dd76273/internal-packages/database/prisma/schema.prisma
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4518/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
https://github.com/triggerdotdev/trigger.dev/pull/4518/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4518/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.