perf(aci): Narrow latest group detector query#115027
Merged
Conversation
The detector serializer was joining every candidate DetectorGroup row to Group and Project before DISTINCT ON picked the newest group. For noisy detectors that meant dragging around a huge joined rowset just to keep one group per detector. Fetch the latest group ids first, then serialize only those groups. Keeps the latestGroup response the same while avoiding the wide joined sort. Co-Authored-By: Codex GPT-5 <noreply@openai.com>
wedamija
approved these changes
May 6, 2026
wedamija
reviewed
May 6, 2026
constantinius
pushed a commit
that referenced
this pull request
May 8, 2026
Fetch the latest DetectorGroup ids first, then load only those groups instead of joining every candidate group before DISTINCT ON. This avoids building and sorting a wide joined Group/Project rowset that mostly gets discarded. A before/after EXPLAIN on the slow detector list page showed execution time drop from 32,400ms to 1,075ms. The wide Group/Project join went from ~99k rows to 20 and the disk sort spill went away.
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.
Fetch the latest DetectorGroup ids first, then load only those groups instead of joining every candidate group before DISTINCT ON.
This avoids building and sorting a wide joined Group/Project rowset that mostly gets discarded.
A before/after EXPLAIN on the slow detector list page showed execution time drop from 32,400ms to 1,075ms. The wide Group/Project join went from ~99k rows to 20 and the disk sort spill went away.
fixes SENTRY-5NPP