René's URL Explorer Experiment


Title: perf(webapp,database): index RuntimeEnvironment.pauseSource for the billing-limit reconcile tick by ericallam · Pull Request #4590 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: perf(webapp,database): index RuntimeEnvironment.pauseSource for the billing-limit reconcile tick by ericallam · Pull Request #4590 · triggerdotdev/trigger.dev

X Title: perf(webapp,database): index RuntimeEnvironment.pauseSource for the billing-limit reconcile tick by ericallam · Pull Request #4590 · triggerdotdev/trigger.dev

Description: What The billingLimit.reconcileTick worker calls getOrgIdsWithBillingPauseSource() on BILLING_LIMIT_RECONCILE_INTERVAL_MS (~every 90s) to find which orgs currently have billing-limit-paused environments. Two problems: RuntimeEnvironment.pauseSource had no index, so WHERE pauseSource = 'BILLING_LIMIT' was a sequential scan of the whole table on the control-plane primary, every tick. Prisma distinct dedups after fetching, so it read every paused row (thousands) to produce a handful of distinct org ids. This PR: Adds a partial index on RuntimeEnvironment (pauseSource, organizationId) WHERE pauseSource IS NOT NULL. Nearly all rows have pauseSource = null, so the index stays tiny. Second column lets the DB satisfy the distinct-org lookup from the index. Defined in SQL (Prisma can't express partial indexes), matching the existing partial-unique indexes on this model. Switches the query from findMany({ distinct }) to groupBy(["organizationId"]), pushing DISTINCT into the DB so it returns only the distinct orgs. Evidence Correctness — colocated postgresTest (testcontainers, no mocks): multiple BILLING_LIMIT envs in one org collapse to one org id, pauseSource = null envs are excluded, each org id returned once. 5/5 tests in billingLimitReconciliation.test.ts pass. Plan change — EXPLAIN ANALYZE on a synthetic table (200k rows, 5,250 BILLING_LIMIT across ~40 orgs, mirroring the test-side numbers from the investigation): Before (no index) After (partial index) Plan Seq Scan (194,750 rows removed by filter) Bitmap Index Scan on partial index Buffers 1355 51 (index 6 + heap 45) Exec time 6.06 ms 0.59 ms Index size 56 kB vs table 11 MB. The key win: cost now scales with the paused-env count, not total table size, which matters most on prod where the table is far larger. Rollout & rollback Index: CREATE INDEX CONCURRENTLY IF NOT EXISTS, in its own migration file. Pre-apply the index manually on the control-plane primary before deploying the migration (the migration is a no-op if the index already exists). Query change is behavior-equivalent (same distinct org set), so no flag needed. Rollback: revert the deploy and drop the index. No data migration either direction. Notes / limitations The planner uses a Bitmap Heap Scan, so organizationId is still read from the heap (45 blocks for the matched rows only, not the whole table). A pure index-only scan isn't chosen for the bitmap path; the second index column keeps that open for the index-scan path at negligible cost. refs TRI-13169

Open Graph Description: What The billingLimit.reconcileTick worker calls getOrgIdsWithBillingPauseSource() on BILLING_LIMIT_RECONCILE_INTERVAL_MS (~every 90s) to find which orgs currently have billing-limit-paused environ...

X Description: What The billingLimit.reconcileTick worker calls getOrgIdsWithBillingPauseSource() on BILLING_LIMIT_RECONCILE_INTERVAL_MS (~every 90s) to find which orgs currently have billing-limit-paused environ...

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

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:f7e0edd7-1804-de14-ffe4-fc349671f8ca
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9F10:31D3B1:9927:C8C5:6AFAF16A
html-safe-nonceb9376ae09a8788435278f1e3dbae84769b9f3cd2f71e62a12d757ba5a756725f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjEwOjMxRDNCMTo5OTI3OkM4QzU6NkFGQUYxNkEiLCJ2aXNpdG9yX2lkIjoiODA1MTc1ODgyMzQ4NTY2NTY0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac0508645f80163f44702a495e718ab9aa98d7213beb9f0cf8a30c9020b4fdfd38
hovercard-subject-tagpull_request:4262355865
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/4590/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:altWhat The billingLimit.reconcileTick worker calls getOrgIdsWithBillingPauseSource() on BILLING_LIMIT_RECONCILE_INTERVAL_MS (~every 90s) to find which orgs currently have billing-limit-paused environ...
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/4590/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F4590%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%2F4590%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/4590/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4590/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/4590/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-13169-billinglimit-reconcile-tick-seq-scans-runtimeenvironmenthttps://github.com/triggerdotdev/trigger.dev/tree/feature/tri-13169-billinglimit-reconcile-tick-seq-scans-runtimeenvironment
Conversation 3 https://github.com/triggerdotdev/trigger.dev/pull/4590
Commits 1 https://github.com/triggerdotdev/trigger.dev/pull/4590/commits
Checks 49 https://github.com/triggerdotdev/trigger.dev/pull/4590/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/4590/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4590/files
perf(webapp,database): index RuntimeEnvironment.pauseSource for the billing-limit reconcile tick https://github.com/triggerdotdev/trigger.dev/pull/4590/files#top
Show all changes 1 commit https://github.com/triggerdotdev/trigger.dev/pull/4590/files
294b2fd perf(webapp,database): index RuntimeEnvironment.pauseSource and push … ericallam Aug 12, 2026 https://github.com/triggerdotdev/trigger.dev/pull/4590/commits/294b2fd8c118674d42c55b6e16916b4c1d367915
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/4590/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4590/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4590/files
billing-limit-reconcile-index.md https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-40841511c5885e3a8d2749c1328da86fdf70bf5256453821db67ec7fb5d96492
billingLimitReconciliation.server.ts https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-16197a9568bf9e79480d7ac2695153d7fe618002d52b30d182227f24459077ca
billingLimitReconciliation.test.ts https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-1180fa0f1332ebf099f719a8c2a200c4e05ecbf7ea249191fa4363108d9c8fec
migration.sql https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-c2850e8756a3201364d1ddf7f3d9c82d6516bebc31020612310589318afd0b3a
.server-changes/billing-limit-reconcile-index.mdhttps://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-40841511c5885e3a8d2749c1328da86fdf70bf5256453821db67ec7fb5d96492
View file https://github.com/triggerdotdev/trigger.dev/blob/294b2fd8c118674d42c55b6e16916b4c1d367915/.server-changes/billing-limit-reconcile-index.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4590/{{ revealButtonHref }}
apps/webapp/app/v3/services/billingLimit/billingLimitReconciliation.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-16197a9568bf9e79480d7ac2695153d7fe618002d52b30d182227f24459077ca
View file https://github.com/triggerdotdev/trigger.dev/blob/294b2fd8c118674d42c55b6e16916b4c1d367915/apps/webapp/app/v3/services/billingLimit/billingLimitReconciliation.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4590/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-16197a9568bf9e79480d7ac2695153d7fe618002d52b30d182227f24459077ca
https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-16197a9568bf9e79480d7ac2695153d7fe618002d52b30d182227f24459077ca
https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-16197a9568bf9e79480d7ac2695153d7fe618002d52b30d182227f24459077ca
apps/webapp/test/billingLimitReconciliation.test.tshttps://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-1180fa0f1332ebf099f719a8c2a200c4e05ecbf7ea249191fa4363108d9c8fec
View file https://github.com/triggerdotdev/trigger.dev/blob/294b2fd8c118674d42c55b6e16916b4c1d367915/apps/webapp/test/billingLimitReconciliation.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4590/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-1180fa0f1332ebf099f719a8c2a200c4e05ecbf7ea249191fa4363108d9c8fec
https://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-1180fa0f1332ebf099f719a8c2a200c4e05ecbf7ea249191fa4363108d9c8fec
...prisma/migrations/20260812120000_add_runtime_environment_pause_source_index/migration.sqlhttps://github.com/triggerdotdev/trigger.dev/pull/4590/files#diff-c2850e8756a3201364d1ddf7f3d9c82d6516bebc31020612310589318afd0b3a
View file https://github.com/triggerdotdev/trigger.dev/blob/294b2fd8c118674d42c55b6e16916b4c1d367915/internal-packages/database/prisma/migrations/20260812120000_add_runtime_environment_pause_source_index/migration.sql
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/4590/{{ revealButtonHref }}
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/4590/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.