-
Notifications
You must be signed in to change notification settings - Fork 12
Optimize queries #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize queries #121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a PostgreSQL materialized view to precompute cumulative team scores per round, reducing query cost for score graph endpoints.
Changes:
- Add
cumulative_scoresmaterialized view + unique index during DB connect. - Switch cumulative score-by-round query to read from the materialized view instead of running a window function per request.
- Refresh the materialized view after each round (asynchronously) and after score resets.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| engine/engine.go | Triggers an async refresh of the cumulative scores materialized view after processing each round. |
| engine/db/servicechecks.go | Reads cumulative scores from cumulative_scores instead of computing via a window function on each call. |
| engine/db/rounds.go | Adds RefreshScoresMaterializedView() helper with concurrent refresh when possible. |
| engine/db/db.go | Creates the cumulative_scores materialized view and index at startup; refreshes it during ResetScores(). |
| IMPLEMENTATION_SUMMARY.md | Documents the materialized view approach, refresh strategy, and rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Looks good to me |
No description provided.