Slow queries in replay endpoints
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
Start with Game.java and the referenced V107__baseline_schema.sql indexes, then inspect later migrations in FAForever/db and the query plan for the map-filtered, newest-first /data/game request. Check whether the proposed composite index is appropriate for this query and how Elide uses it. Done means the change is measured against the reported slow search and its impact on other queries is considered.
索引モデルが issue の本文から書いたものです。
説明
Searching games by map is slow for popular maps
Searching /data/game with a filter on the map name takes up to 20 seconds when the map is popular. The same search without the sort, or with a player filter added, answers in under 0.2 s. Claude says this may be because of a missing index. This would be a small change, but I can't oversee the exact implications myself. Essentially this is suggested:
A composite index in FAForever/db:
CREATE INDEX game_stats_mapId_startTime ON game_stats (mapId, startTime);
I've always noticed that the replay tab can be quite slow, this has been happening for years. I only make this ticket because I noticed that it may be a small fix. But I don't know how Elide interacts with an additional index. If I am totally off based on your gut, then feel free to close this immediately.
The query
The web vault (https://vault.jipwijnia.nl) searches games like this, 12 per page, newest first:
GET /data/game
?include=playerStats,playerStats.player,mapVersion,mapVersion.map,featuredMod
&sort=-startTime
&page[size]=12&page[number]=7
&page[totals]
&filter=endTime=isnull=false;mapVersion.map.displayName=="*Seton*"
Measurements
Measured on 2026-10-06 from a browser, with a bearer token. The API caches answers per URL (repeating a URL returns in about 55 ms), so each search was run three times with a different page (7, 8 and 9) to make every call uncached. The three runs were within 2% of each other.
Search (all with endTime=isnull=false) |
Matching games | Time |
|---|---|---|
| No other filter | 19.2 million | 1.25 s |
No other filter, no page[totals] |
0.08 s | |
| Player (a player with about 5,000 games) | 5,087 | 0.22 s |
Map *Seton* |
1.35 million | 20.8 s |
Map *Seton*, no page[totals] |
19.1 s | |
Map *Seton*, no page[totals], no include |
19.0 s | |
Map *Seton*, no page[totals], no sort |
0.09 s | |
Map "Seton's Clutch" (exact), no page[totals] |
14.8 s | |
Map *Fields of Isis*, no page[totals] |
4.6 s | |
Map *Theta Passage*, no page[totals] |
1.1 s | |
Player and map *Seton* |
834 | 0.14 s |
The moment I search for a map with many replays + sorting the endpoint time explodes.
Suspected cause
Game maps to game_stats and reaches the map through mapId → map_version → map. In the schema, game_stats has separate indexes on mapId and on startTime (twice: startTime and game_stats_startTime_index), but none on both together. No later migration adds one.
So for "the newest 12 games on this map" the database has to either collect all games of the map's versions through mapId and sort them (1.35 million rows for Seton), or walk all games backwards through startTime and check the map of each. Both fit the timings above: fast without the sort, slower the more the map is played.
- 主要言語
- Java
- スター
- 31
- フォーク
- 30
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
FAForever/faf-java-api のほかの issue
-
Replay review requests from the client, via the api and RabbitMQ再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
FAForever/faf-java-api#1181 · コメント 12 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
FAForever/faf-java-api#895 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
FAForever/faf-java-api#816 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
FAForever/faf-java-api#708 · コメント 13 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
FAForever/faf-java-api#496 · コメント 1 件 ·
FAForever/faf-java-api の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
PCL-Community/PCL-CE#3658 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Team/Identity Server Core Type/Improvement U2
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
wso2/product-is#28553 ·
メンテナーはふだん 1 日以内に返信
-
frontend
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
Paul-Austin-Oswego-CSC480-HCI521/gift-app#116 ·
メンテナーはふだん 2 日以内に返信
-
dependencies java
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
micrometer-metrics/tracing#1588 ·
メンテナーはふだん 1 日以内に返信