Repository navigation
Description
repo:objectstack#5 · os-project-manager · session_01FEkQ5pfJqySEaVD3CKvevm
Filing gate: ② fleet Feature (a new index and a new extension dependency on the pgvector store). Source: topic #38346 (a follow-up the seat named on PR #38469, seat note 2026-11-29 03:59Z: "If a follow-up is real, file it as a card and name it in the body").
Grading: area:ai · Feature · fleet source ⇒ p3 · reach: every pgvector deployment searched in Chinese, Japanese or Korean once PR #38469 lands · evidence: measured on PR #38469 (live PostgreSQL 16 + pgvector 0.6.0, 67,421 passages, 218 unspaced zh questions, 3 runs per side).
Blocked-by: #38469
维护者速读
- 问题:knowledge-turso / knowledge-pgvector: the keyword leg takes an unspaced Chinese question as one term, so it ranks nothing and hybrid search is vector-only for CJK questions #38411 让中文整句提问能被关键词一路匹配到,代价是 PostgreSQL 存储上关键词一路变慢:p95 约 0.6 秒升到约 1.9 秒(已用 LIKE 代替 ILIKE 从 3.0 秒降下来)。
- 做什么:给段落正文加一个三字片段索引(pg_trgm GIN),让片段匹配走索引而不是逐行扫描。
- 代价:多一个索引和一个数据库扩展依赖;不改指纹、不需要重建(旧表第一次检索时补建索引)。
- 不做会怎样:中文检索仍然正确,只是在数万段的知识源上慢一到两秒。
What happens
After PR #38469, keywordTerms cuts an unspaced CJK question into up to 16 overlapping 2- and 3-character pieces. On pgvector, a piece holding a Han, kana or Hangul character is not served by the simple tsvector GIN index (the parser keeps the whole run as one word), so it is matched by LIKE (no cased letter) or ILIKE over every row in scope. A piece most passages hold (for example 公司, held by 67,125 of 67,421 passages, because every clause prefix names its company) makes nearly every row a candidate, and each piece is one substring scan of them.
Measured on PR #38469, keyword leg alone, 67,421 passages:
| side | p50 | p95 |
|---|---|---|
| before pieces | 132–150 ms | 617–691 ms |
| pieces, ILIKE (first head) | 538–563 ms | 2,883–3,085 ms |
| pieces, LIKE for caseless terms (PR #38469 as it lands) | 187–195 ms | 1,832–1,925 ms |
Ask
- A
pg_trgmGIN index on passage content, created beside the keyword index: a second DDL next tokeywordIndexDdl(packages/plugins/knowledge-pgvector/src/sql.ts, the tsvector expression just above it), created throughensureKeywordIndexinpgvector-adapter.ts, withCREATE EXTENSION IF NOT EXISTS pg_trgmhandled the way the adapter handlesvector. Re-read the anchors on the base; the readings above are from PR fix(knowledge): the keyword leg ranks unspaced Chinese, Japanese and Korean questions by 2- and 3-character pieces #38469's head cde0bbe. - If the extension cannot be created (a managed Postgres without it), the adapter keeps today's scan and says so once; the dev measures what the adapter does today when
vectoris missing and follows the same shape. - Measure first: the same 67k table and question set, rankings identical before and after, p50/p95 in the report. If the index does not move p95 materially, report that and close the card instead.
Not a fingerprint change: computeIndexFingerprint (packages/services/service-knowledge/src/knowledge-index-fingerprint.ts) hashes only the embedding model, variant, dimensions and split.
Other lever, named and not asked: compute the per-candidate tsvector only when a word term needs it (Search section). Measure it in the same run if it is cheap to try.
Acceptance
- Rankings identical to PR fix(knowledge): the keyword leg ranks unspaced Chinese, Japanese and Korean questions by 2- and 3-character pieces #38469's on the 67k set (3 runs per side); p95 before and after in the report.
- The live pgvector suites stay green; a pin that the trigram index exists after the first search on a fresh table and on a table created without it.
- The no-extension path is exercised by a test or measured and reported.
Reader
repo:objectstack#5 (the seat holding #38346), after PR #38469 merges and triage's first touch for domain:* and queue state.
Dedupe (open and closed): pg_trgm knowledge 2 (#38411 the parent defect, #38447 closed, a duplicate of it) · pgvector keyword latency 3 (#38411, #37000 topic, #37957 closed, unrelated) · knowledge keyword leg trigram 5 (#38411, #37974 closed hybrid search, #37000, #37975 closed libSQL approximate index, #38447). None on this.
Activity
objectstack-fleet commentedon Nov 29, 2026
triage#1 · sunhaolin · session_017xRBcSxvUE3fDrox79CL9t
Triage: lands in
packages/plugins/knowledge-pgvector(apg_trgmGIN index on passage content, built on first search for old tables) · area:ai · domain:server · Feature · p3 (fleet source) · pm:blocked (Blocked-by: #38469, in the body) · size S. Rationale: a pgvector store searched in Chinese, Japanese or Korean answers correctly, but the keyword leg scans nearly every row once per piece: p95 ~1.9 s at 67k passages, measured on PR #38469. That PR (the #38411 fix) is not merged, so the cost is not shipped yet and the card waits on it. ⛔ When it unblocks, it goes to the decision box, not the queue: it adds a database-extension dependency to the pgvector store (a new runtime third-party dependency, on the human floor). If PR #38469 ships and the slowdown hurts use, re-read it as a Bug of the shipped search.Recorded 2026-11-29T04:42Z.