Repository navigation
db: aggregate run summaries with GROUP BY instead of row-by-row iteration - #18
Open
fumblehool wants to merge 1 commit into
Open
fumblehool wants to merge 1 commit into
fumblehool wants to merge 1 commit into
Conversation
…tion ListRunSummariesInRange previously returned one row per (run, test) pair and iterated in Go to count tests by state. For the dashboard's 30-day call this meant ~100k rows and parsing test result JSON for each. Switch to GROUP BY runs.id with count(*) FILTER (WHERE result->>'state' = '...') to aggregate test counts in SQL. This: - Reduces rows from O(tests) to O(runs) (~100k → ~3k for 30 days) - Pushes state classification to Postgres, eliminating JSON parsing in Go - Simplifies the iteration logic (one pass over runs, no seenRuns map) PackageSummary now stores PassedCount/FailedCount/SkippedCount integers instead of map[string][]uuid.UUID per state. The /run_summary page shows aggregate counts and links to runs for individual test details. Follow-up to the approach suggested in PR #16 review: use GROUP BY to push more computation to Postgres rather than extracting fields row-by-row.
ElanHasson
approved these changes
Oct 20, 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.
PR details:
ListRunSummariesInRange previously returned one row per (run, test) pair and iterated in Go to count tests by state. For the dashboard's 30-day call this meant ~100k rows and parsing test result JSON for each.
Switch to GROUP BY runs.id with count(*) FILTER (WHERE result->>'state' = '...') to aggregate test counts in SQL. This:
PackageSummary now stores PassedCount/FailedCount/SkippedCount integers instead of map[string][]uuid.UUID per state. The /run_summary page shows aggregate counts and links to runs for individual test details.
Follow-up to the approach suggested in PR #16 review: use GROUP BY to push more computation to Postgres rather than extracting fields row-by-row.