mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
7cd051d7f7
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.