7–56 s → 0.9–1.6 s
記憶搜尋最佳化Memory search optimization
- Problem
- 圖譜長到上萬條關係後,搜尋開始逾時,連帶卡住寫入。Past ten thousand relations, search began timing out and stalling writes.
- Decision
- 追到資料庫的查詢計畫:全文搜尋的每個命中都重新掃描全部實體,成本是「命中數 × 實體數」。改成直接取用命中關係的兩端節點。Traced the database query plan: every full-text hit rescanned all entities — cost hits × entities. Switched to reading each hit's endpoints directly.
- Result
- 同一批查詢、結果完全相同,時間降到 0.9–1.6 秒。Same queries, identical results, 0.9–1.6 s.
驗證方式How it was verified
- 先以唯讀方式在正式圖譜上比對新舊寫法,回傳的關係、節點與分數逐筆相同。
- 寫入流程在隔離的臨時資料庫驗證(寫入、搜尋、刪除),通過後才上線。
- 上線後連續萃取未再出現逾時。
- Compared old and new queries read-only on the production graph: returned relations, nodes and scores matched row for row.
- Validated the write path (add, search, delete) in an isolated throwaway database before shipping.
- No timeouts in consecutive extractions after release.