Repository navigation
Commit b0a68f2
authored
fix(knowledge): keep vector candidate selection bounded (#7960)
* fix(knowledge): keep vector candidate selection bounded
An underfilled ANN traversal rescored the whole compact projection and joined the
visible document set to it. That fallback is O(corpus): on a 132k-chunk index it
took 1.9s, and on a corpus an order of magnitude larger it exceeds the retrieval
budget, so the vector leg returned nothing at all rather than fewer rows.
Widening the search has no affordable form here. Measured at 10% visibility on the
same index, scanning 6.5k tuples instead of 1.5k took 5.1s and 9.7s on consecutive
identical runs, and joining visibility before scoring took 8.4s because it turns a
sequential scan into a random lookup per document. The bounded traversal itself
costs ~115ms whether or not it fills.
The traversal is now the whole candidate set. An underfilled one yields fewer
candidates and is reported as such, which strictly beats a leg that times out.
* fix(knowledge): match the latency plan assertions to the bounded traversal
The plan assertion still required the removed CTEs, and the predicates selecting
which captured query to assert against matched the old CTE name with a lowercase
fallback the rendered statement never produces. The candidate assertions would
have stopped running rather than failing, so they now key on the visibility
lateral through one shared predicate.
The plan check drops the fallback-specific expectations and gains the one that
guards this change: the traversal must never reach the projection by document
lookup or sequential scan, at any candidate count.1 parent 8396028 commit b0a68f2
4 files changed
Lines changed: 79 additions & 104 deletions
File tree
- apps/sim/lib/knowledge
- __integration__
- search
Lines changed: 31 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
| |||
218 | 227 | | |
219 | 228 | | |
220 | 229 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
228 | 242 | | |
229 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
230 | 246 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 247 | + | |
| 248 | + | |
246 | 249 | | |
247 | 250 | | |
248 | 251 | | |
| |||
294 | 297 | | |
295 | 298 | | |
296 | 299 | | |
297 | | - | |
| 300 | + | |
298 | 301 | | |
299 | 302 | | |
300 | 303 | | |
| |||
472 | 475 | | |
473 | 476 | | |
474 | 477 | | |
475 | | - | |
| 478 | + | |
476 | 479 | | |
477 | 480 | | |
478 | 481 | | |
| |||
497 | 500 | | |
498 | 501 | | |
499 | 502 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
| 503 | + | |
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
517 | | - | |
518 | | - | |
| 517 | + | |
519 | 518 | | |
520 | 519 | | |
521 | 520 | | |
| |||
526 | 525 | | |
527 | 526 | | |
528 | 527 | | |
529 | | - | |
| 528 | + | |
530 | 529 | | |
531 | 530 | | |
532 | 531 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
87 | | - | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
438 | | - | |
439 | | - | |
| 437 | + | |
440 | 438 | | |
441 | 439 | | |
442 | 440 | | |
| |||
501 | 499 | | |
502 | 500 | | |
503 | 501 | | |
504 | | - | |
505 | | - | |
506 | | - | |
| 502 | + | |
507 | 503 | | |
508 | 504 | | |
509 | 505 | | |
| |||
516 | 512 | | |
517 | 513 | | |
518 | 514 | | |
519 | | - | |
520 | | - | |
521 | | - | |
| 515 | + | |
522 | 516 | | |
523 | 517 | | |
524 | 518 | | |
| |||
534 | 528 | | |
535 | 529 | | |
536 | 530 | | |
537 | | - | |
538 | | - | |
539 | | - | |
| 531 | + | |
540 | 532 | | |
541 | 533 | | |
542 | 534 | | |
| |||
616 | 608 | | |
617 | 609 | | |
618 | 610 | | |
619 | | - | |
620 | | - | |
621 | | - | |
| 611 | + | |
622 | 612 | | |
623 | 613 | | |
624 | 614 | | |
| |||
807 | 797 | | |
808 | 798 | | |
809 | 799 | | |
810 | | - | |
| 800 | + | |
811 | 801 | | |
812 | 802 | | |
813 | 803 | | |
| |||
841 | 831 | | |
842 | 832 | | |
843 | 833 | | |
844 | | - | |
| 834 | + | |
845 | 835 | | |
846 | | - | |
847 | 836 | | |
848 | 837 | | |
849 | 838 | | |
| |||
922 | 911 | | |
923 | 912 | | |
924 | 913 | | |
925 | | - | |
| 914 | + | |
926 | 915 | | |
927 | 916 | | |
928 | 917 | | |
| |||
933 | 922 | | |
934 | 923 | | |
935 | 924 | | |
936 | | - | |
| 925 | + | |
937 | 926 | | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
942 | 931 | | |
943 | 932 | | |
944 | 933 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
902 | 906 | | |
903 | 907 | | |
904 | 908 | | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
909 | 919 | | |
910 | 920 | | |
911 | 921 | | |
912 | | - | |
913 | | - | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | | - | |
921 | | - | |
922 | | - | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
948 | 934 | | |
949 | 935 | | |
950 | 936 | | |
951 | | - | |
952 | 937 | | |
953 | 938 | | |
954 | | - | |
955 | | - | |
| 939 | + | |
956 | 940 | | |
957 | 941 | | |
958 | 942 | | |
| |||
0 commit comments