Skip to content

perf(sourcemaps): Flip debug-id EXISTS query to drive from project side#112673

Closed
scttcper wants to merge 1 commit intomasterfrom
scttcper/fix-debug-id-query-perf
Closed

perf(sourcemaps): Flip debug-id EXISTS query to drive from project side#112673
scttcper wants to merge 1 commit intomasterfrom
scttcper/fix-debug-id-query-perf

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented Apr 10, 2026

#112627 replaced the double join (DebugIdArtifactBundle -> ArtifactBundle -> ProjectArtifactBundle) with a correlated EXISTS subquery.

This flips the query to start from ProjectArtifactBundle (scoped by project_id, much smaller) as the outer table, with the EXISTS probing DebugIdArtifactBundle by the FK index on artifact_bundle_id. Same semantics, but Postgres starts from the small side.

The `has_uploaded_some_artifact_with_a_debug_id` query was scanning
`sentry_debugidartifactbundle` by `organization_id` (potentially
millions of rows for large orgs) then probing
`sentry_projectartifactbundle` via correlated EXISTS for each candidate.

Flips the query to start from `ProjectArtifactBundle` scoped by
`project_id` (much smaller set) and probe `DebugIdArtifactBundle` by
the FK index on `artifact_bundle_id`. Same semantics, better plan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Made-with: Cursor
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 10, 2026
@scttcper scttcper closed this Apr 10, 2026
@scttcper scttcper deleted the scttcper/fix-debug-id-query-perf branch April 10, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant