perf(usage): 优化 admin usage records 查询性能

- count 查询按需 JOIN,避免不必要的表关联
- 前端 onMounted 将 stats/heatmap/records/users 全部并行加载
- 调整缓存 TTL(聚合 30s->60s,列表 10s->15s)
- 为 request_candidates 添加复合索引优化 fallback/retry 查询
This commit is contained in:
fawney19
2026-02-28 15:09:21 +08:00
parent 11832edf49
commit 4fdebfc78e
5 changed files with 127 additions and 47 deletions

View File

@@ -2203,6 +2203,10 @@ class RequestCandidate(Base):
Index("idx_request_candidates_status", "status"),
Index("idx_request_candidates_provider_id", "provider_id"),
Index("idx_request_candidates_created_at", "created_at"),
# 复合索引: 按 request_id + status 查询 fallback/retry 场景
Index("idx_rc_request_id_status", "request_id", "status"),
# 复合索引: 按 provider 聚合统计provider_id + status + created_at
Index("idx_rc_provider_status_created", "provider_id", "status", "created_at"),
)
# 关系