用户名筛选:user_id 先查成字面列表,不再把子查询夹在 OR 里(那样整条 OR 不可索引), 加 trigram 索引接住 ilike '%x%';翻页先圈出匹配行再排序取页,避开规划器顺着时间索引 倒扫、边扫边滤的计划。快照上查一个班 70~107ms → 5~14ms;匹配 9.5 万条的年级前缀 从 34ms 变成 70~90ms,实际不这么查。 题号筛选:先解析成 problem.id,加 (problem_id, create_time, id) 部分索引。老题和 不存在的题号不再倒扫大半张表(34~67ms → 4ms),题号筛选也能走游标深翻页, count 不再 join problem。 迁移 0015 装 pg_trgm(官方镜像自带 contrib,trusted 扩展)。39 个筛选组合的响应 与改动前逐字节一致。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xg91q3JsunDE7EYoi9G3i2
This commit is contained in:
@@ -106,6 +106,13 @@
|
||||
"when": 1789034426259,
|
||||
"tag": "0014_drop_django_migrations",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 15,
|
||||
"version": "7",
|
||||
"when": 1789364546358,
|
||||
"tag": "0015_submission_filter_indexes",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user