Skip to content

db: aggregate run summaries with GROUP BY instead of row-by-row iteration - #18

Open
fumblehool wants to merge 1 commit into
mainfrom
ui/run-details-enhancement
Open

fumblehool wants to merge 1 commit into
mainfrom
ui/run-details-enhancement

Conversation

@fumblehool

Copy link
Copy Markdown
Collaborator

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:

  • 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants