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-22 16:10:01 -07: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-23 04:00:17 +01:00
2026-04-20 22:05:39 +01:00
2026-04-21 00:32:42 +01:00
2026-04-22 23:16:57 +01:00
2026-04-22 23:19:20 +01:00
2026-04-22 23:16:57 +01:00
2026-04-20 13:16:40 +01:00
2026-04-22 04:51:38 +01:00
2026-04-20 20:55:39 +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-23 03:35:32 +01:00
2026-04-21 00:32:42 +01:00
2026-04-22 03:31:09 -05:00
2026-04-20 13:18:32 +01:00
2026-04-22 16:14:23 -07:00
2026-04-22 23:16:57 +01:00
2026-04-20 22:05:39 +01:00
2026-04-23 03:35:32 +01:00
2026-04-21 02:34:24 +01:00
2026-04-21 00:54:08 +01:00
2026-04-22 23:16:57 +01:00
2026-04-22 23:19:20 +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-22 19:13:51 +01:00
2026-04-22 06:11:49 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 13:16:40 +01:00
2026-04-22 23:16:57 +01:00
2026-04-22 06:47:51 +01:00
2026-04-22 04:51:38 +01:00
2026-04-23 04:00:17 +01:00
2026-04-22 23:16:57 +01:00
2026-04-20 13:16:40 +01:00
2026-04-21 09:13:35 +01:00
2026-04-23 04:00:17 +01:00
2026-04-21 05:32:13 +01:00
2026-04-22 11:45:33 -07:00
2026-04-22 06:47:51 +01:00
2026-04-20 13:16:40 +01:00
2026-04-23 04:01:47 +01:00
2026-04-22 16:06:55 -07:00
2026-04-20 23:34:19 +01:00
2026-04-21 00:24:18 +01:00
2026-04-20 13:16:40 +01:00
2026-04-22 06:11:49 +01:00
2026-04-23 03:35:32 +01:00
2026-04-23 01:52:58 +01:00
2026-04-22 19:05:53 +01:00
2026-04-22 06:47:51 +01:00
2026-04-22 19:13:51 +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-22 06:11:49 +01:00
2026-04-23 02:20:10 +01:00
2026-04-21 02:34:24 +01:00
2026-04-17 10:14:00 +05:30
2026-04-22 02:56:23 +01:00
2026-04-23 03:49:04 +01:00
2026-04-23 01:21:52 +01:00
2026-04-21 02:41:26 +01:00
2026-04-22 20:03:33 +08:00
2026-04-22 06:11:49 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 20:55:39 +01:00
2026-04-22 19:13:51 +01:00
2026-04-22 14:39:58 -07:00
2026-04-23 02:42:48 +01:00
2026-04-22 10:08:57 +05:30
2026-04-20 13:16:40 +01:00
2026-04-21 12:00:28 -06:00
2026-04-20 13:16:40 +01:00
2026-04-17 10:14:00 +05:30
2026-04-22 23:19:20 +01:00
2026-04-23 01:39:56 +01:00
2026-04-21 22:46:07 -07:00
2026-04-21 00:32:42 +01:00
2026-04-22 14:19:13 -07:00
2026-04-23 04:00:17 +01:00
2026-04-20 23:04:10 +01:00
2026-04-22 08:52:55 +01:00
2026-04-21 00:40:07 +01:00
2026-04-20 20:55:39 +01:00
2026-04-22 04:51:38 +01:00
2026-04-20 13:16:40 +01:00
2026-04-20 20:55:39 +01:00
2026-04-22 01:43:18 +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-22 19:13:51 +01:00
2026-04-23 04:00:17 +01:00
2026-04-20 13:16:40 +01:00
2026-04-22 06:11:49 +01:00
2026-04-23 01:02:57 +01:00
2026-04-22 19:05:53 +01:00
2026-04-17 02:23:49 -04:00
2026-04-20 22:09:16 +01:00
2026-04-06 15:38:04 +01:00
2026-04-09 23:59:00 +01:00
2026-04-20 22:09:16 +01:00