Files
openclaw/extensions
aalekh-sarvam 7cd051d7f7 fix(memory): use sqlite-vec KNN for searchVector (190x speedup)
Replace full-table scan via vec_distance_cosine() + ORDER BY LIMIT with
sqlite-vec's native MATCH + k = ? KNN operator. Keep vec_distance_cosine()
in the SELECT so score = 1 - dist preserves the existing cosine [0,1]
semantics the downstream merge pipeline depends on.

Fixes #69666.

Benchmark on 10,827 chunks, 4096-dim embeddings:
- Before (full scan):  ~8490 ms/query
- After  (KNN + join): ~50 ms/query

No behavioral changes: returned ids and ordering are identical to the
previous query on all tested queries. The LIMIT ? binding is replaced by
k = ? which caps sqlite-vec's candidate set to the same count.
2026-04-23 04:01:47 +01:00
..
2026-04-22 23:19:20 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-21 00:54:08 +01:00
2026-04-20 13:16:40 +01:00
2026-04-21 00:54:08 +01:00
2026-04-23 04:00:17 +01:00
2026-04-23 04:00:17 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 16:34:48 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00