perf(issues): Avoid slow double-join in source-map-debug-blue-thunder-edition#112627
Merged
perf(issues): Avoid slow double-join in source-map-debug-blue-thunder-edition#112627
Conversation
…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>
scttcper
commented
Apr 9, 2026
| 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 |
Member
Author
There was a problem hiding this comment.
we don't need to make a query at all if one of these other queries has results, scanning the same thing.
wedamija
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
has_uploaded_some_artifact_with_a_debug_idexistence 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
EXISTSsubquery 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