Repository navigation
Avoid a full miner_predictions scan when loading scores - #337
Merged
Merged
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The added predicate matches the score timestamp construction and preserves existing query results.
0 open findings
What changed in this PR
Optimizes score loading by adding a logically equivalent time bound that enables indexed request and prediction lookups.
Changes:
- Adds an indexed
validator_requests.start_timeconstraint. - Documents the query-plan improvement and validation results.
| File | Description |
|---|---|
synth/validator/miner_data_handler.py |
Avoids a full miner_predictions scan when loading scores. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Thykof
approved these changes
Oct 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.
get_miner_scores never bounds validator_requests in time, so the planner can't use the asset/time_length predicates to restrict the join and falls back to a full scan of miner_predictions before filtering. A prediction is scored exactly when its window closes — scored_time = vr.start_time + time_length — so the added bound is implied by the existing scored_time filter and removes no rows. Plan cost 5.59M → 2.09M; 110s → 30s on a 10-day window; verified identical over a fixed window: 491,520 rows both sides, zero rows in either EXCEPT, matching md5 across the full result set including computed window values. The invariant was checked separately: 0 violations across 3.7M rows over 14 days.