3.4 KiB
3.4 KiB
id, title, status, type, team, supporting_teams, roadmap_item, priority
| id | title | status | type | team | supporting_teams | roadmap_item | priority | |
|---|---|---|---|---|---|---|---|---|
| TASK-189-add-ranking-materialized-read-indexes | Add ranking materialized read indexes | pending | backend | Arquitecto de Base de Datos |
|
foundation | high |
TASK-189 - Add ranking materialized read indexes
Goal
Add safe indexes on the materialized tables used by Ranking and Stats to reduce scans and improve join performance.
Context
The current Ranking and Stats runtime reads depend on rcon_materialized_matches, rcon_match_player_stats and annual snapshot tables. After TASK-188 documents the real bottlenecks, HLL Vietnam needs a narrow indexing pass that improves read performance without changing API contracts, recalculating rankings or introducing a second architecture.
Preserve the current product identity: Spanish-speaking HLL Vietnam community, military/Vietnam/tactical/sober visual direction and controlled repository evolution.
Steps
- Read the listed files first.
- Use
docs/ranking-stats-performance-audit.mdas the primary justification source. - Add only the indexes supported by the audit findings and the existing storage initialization/migration pattern.
- Keep SQLite/Postgres compatibility if both storage modes are supported in the current backend.
- Re-run the validation scripts and, if possible, compare before/after timing for one or two representative endpoints.
Files to Read First
AGENTS.mdai/repo-context.mdai/architecture-index.mddocs/ranking-stats-performance-audit.mdbackend/app/rcon_admin_log_materialization.pybackend/app/rcon_historical_leaderboards.pybackend/app/rcon_historical_player_stats.pybackend/app/rcon_annual_rankings.pybackend/app/postgres_rcon_storage.pybackend/app/sqlite_utils.py
Expected Files to Modify
backendstorage/migration/init module correspondiente, según patrón existentedocs/ranking-stats-performance-audit.md, solo si se documenta índice aplicadoai/tasks/done/TASK-189-add-ranking-materialized-read-indexes.md
Constraints
- No cambiar contratos API.
- No cambiar frontend.
- No recalcular rankings.
- No crear snapshots en esta task.
- No reactivar Elo/MMR.
- No reintroducir Comunidad Hispana #03.
- Mantener compatibilidad SQLite/Postgres si el proyecto usa ambos.
- Basar los índices en evidencia documentada por
TASK-188, no en suposiciones.
Validation
Before completing the task ensure:
- the chosen indexes are justified by
TASK-188 - candidate coverage explicitly considers:
target_key + match_keysource_basis + ended_at/started_attarget_key + ended_at/started_atplayer_idplayer_nameif search benefits from itsnapshot_id + ranking_positionin snapshot tables if applicable
powershell -ExecutionPolicy Bypass -File scripts/run-stats-validation.ps1powershell -ExecutionPolicy Bypass -File scripts/run-integration-tests.ps1- if possible, before/after timing is captured for one or two endpoints
- any measurement limitations are documented
git diff --name-onlystays within scope
Outcome
Document:
- indexes added
- why each index was chosen
- observed improvement or inability to measure it
- residual performance gaps that still require snapshot-based reads
Change Budget
- Prefer fewer than 5 modified files.
- Prefer changes under 200 lines when feasible.
- Split the work into follow-up tasks if limits are exceeded.