- 「画流程图 / 语法要求 / 有参考图」标签不再各自调 useDark():vueuse 每个实例都会重写 <html> 的 class、插一段禁用过渡的样式再强制整页重算,一页十几个标签就重算十几遍。 明暗两套色改走 CSS(html.dark)。每次切换 Vue 更新 46ms → 15ms、样式重算 24ms → 1.6ms - 新索引 submission_public_problem_user_idx(problem_id, user_id, result,只含公开提交): 每页「做对 / 做过人数」原来要把以 user_id 打头的索引 11 万行扫一遍。 列表接口 19ms → 9ms,「最多人做对」排序 55ms → 26ms - 第一次打开、没带筛选时,不再单独多数一次题目总数 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed7752afbb
commit
74af88046e
6 files changed
+4196
-21
No files matched your search
@@ -906,6 +906,24 @@ export const submission = pgTable(
|
||||
table.createTime.asc().nullsLast(),
|
||||
)
|
||||
.where(sql`${table.contestId} is null`),
|
||||
/**
|
||||
* 题目列表每一页的「做对 / 做过人数」(`services/problem-progress.ts` 的
|
||||
* problemUserCounts):按 problem_id 取一页 30 道题、数 distinct user_id。
|
||||
* 上面那条以 user_id 打头,按题号查只能把整棵索引 11 万行扫一遍再滤,12–18ms 而且
|
||||
* 随提交数线性涨;这条以 problem_id 打头,快照实测 12ms → 3.6ms,「最多人做对」排序
|
||||
* 的全表聚合 85ms → 16ms。
|
||||
*
|
||||
* problem_user_idx 也以 problem_id 打头,但它不是部分索引、也不带 result,规划器
|
||||
* 不选它(还得回表看 contest_id 和 result)。
|
||||
*/
|
||||
index("submission_public_problem_user_idx")
|
||||
.using(
|
||||
"btree",
|
||||
table.problemId.asc().nullsLast(),
|
||||
table.userId.asc().nullsLast(),
|
||||
table.result.asc().nullsLast(),
|
||||
)
|
||||
.where(sql`${table.contestId} is null`),
|
||||
foreignKey({
|
||||
columns: [table.contestId],
|
||||
foreignColumns: [contest.id],
|
||||
|
||||
Reference in new issue
Block a user