Skip to content

perf(issues): Avoid slow double-join in source-map-debug-blue-thunder-edition#112627

Merged
scttcper merged 1 commit intomasterfrom
scttcper/sourcemap-debug-perf
Apr 9, 2026
Merged

perf(issues): Avoid slow double-join in source-map-debug-blue-thunder-edition#112627
scttcper merged 1 commit intomasterfrom
scttcper/sourcemap-debug-perf

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented Apr 9, 2026

The has_uploaded_some_artifact_with_a_debug_id existence check joins DebugIdArtifactBundle -> ArtifactBundle -> ProjectArtifactBundle with only org_id + project_id filters. For large orgs this scans millions of rows in DebugIdArtifactBundle.

Replace the double join with a correlated EXISTS subquery so Postgres can use the (project_id, artifact_bundle) composite index on ProjectArtifactBundle directly.

Skip the query entirely when the event's own debug IDs already matched uploaded artifacts.

fixes SENTRY-2JS6

…ition

The `has_uploaded_some_artifact_with_a_debug_id` existence check was
joining DebugIdArtifactBundle → ArtifactBundle → ProjectArtifactBundle
with only org_id + project_id filters. For large orgs this scans
millions of rows in DebugIdArtifactBundle before finding a match.

Replace the double join with a correlated EXISTS subquery so Postgres
can use the (project_id, artifact_bundle) composite index on
ProjectArtifactBundle directly. Also short-circuit the query entirely
when the event's own debug IDs already matched uploaded artifacts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 9, 2026
@scttcper scttcper changed the title perf(api): Avoid slow double-join in source-map-debug-blue-thunder-edition perf(issues): Avoid slow double-join in source-map-debug-blue-thunder-edition Apr 9, 2026
@scttcper scttcper requested a review from a team April 9, 2026 21:35
@scttcper scttcper marked this pull request as ready for review April 9, 2026 21:35
@scttcper scttcper requested a review from a team as a code owner April 9, 2026 21:35
debug_ids_with_uploaded_source_map.add(str(debug_id_artifact_bundle.debug_id))

has_uploaded_some_artifact_with_a_debug_id = bool(
debug_ids_with_uploaded_source_file or debug_ids_with_uploaded_source_map
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we don't need to make a query at all if one of these other queries has results, scanning the same thing.

@scttcper scttcper merged commit 3fde1ea into master Apr 9, 2026
63 checks passed
@scttcper scttcper deleted the scttcper/sourcemap-debug-perf branch April 9, 2026 23:05
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.

2 participants