perf(db): 标题模糊匹配改用 % 运算符走 trigram 索引,巡检回填加部分索引,删除无用索引
- 别名 / 资源标题模糊匹配原来写 similarity(x, q) >= t,函数调用用不上 trigram 索引;改为 x % q and similarity(x, q) >= t(% 缺省阈值 0.3 不高于各处阈值,结果相同)。source_release 标题搜索 在部署规模(8440 行)从约 75 ms 降到 0.7 ms - 调度器每 15 秒的巡检回填原来整扫 scheduled_job_run:迁移 0089 加部分索引 scheduled_job_run_harvest_idx - 迁移 0089 删除没有任何查询会用到的 content_unit_air_date_idx;镜像带 pg_stat_statements 时建扩展, 没有或权限不够时跳过,不让迁移失败 - gen:types 跳过扩展自带的视图(public.pg_stat_statements) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
155f30417c
commit
9fffee16c8
9 files changed
+69
-8
No files matched your search
@@ -289,7 +289,10 @@ export class Scheduler {
|
||||
if (manual || status !== job.last_status || status === "failed") this.publish(job.id, status);
|
||||
}
|
||||
|
||||
/** 巡检入队的 agent_run 结束后:回填终态与摘要;配置了 reportAsDecision 的写一条 info 待处理 */
|
||||
/**
|
||||
* 巡检入队的 agent_run 结束后:回填终态与摘要;配置了 reportAsDecision 的写一条 info 待处理。
|
||||
* 条件与部分索引 scheduled_job_run_harvest_idx(迁移 0089)一致,每 15 秒一次不再全表扫运行历史。
|
||||
*/
|
||||
async harvest(): Promise<number> {
|
||||
const rows = await sql<{
|
||||
id: string;
|
||||
@@ -304,7 +307,7 @@ export class Scheduler {
|
||||
from scheduled_job_run r
|
||||
join scheduled_job j on j.id = r.job_id
|
||||
join agent_run a on a.id = r.agent_run_id
|
||||
where r.agent_status is null and a.status = any(${TERMINAL_AGENT})
|
||||
where r.agent_status is null and r.agent_run_id is not null and a.status = any(${TERMINAL_AGENT})
|
||||
limit 50`.execute(this.db);
|
||||
for (const r of rows.rows) {
|
||||
const summary = (r.summary ?? "").trim() || `智能体运行结束:${r.status}`;
|
||||
|
||||
Reference in new issue
Block a user