Update search anti-pattern guidance
ober
cf6b57cc72f00c1b0a19b531da9ed72711adeb17
--- a/data/anti-patterns.sexp +++ b/data/anti-patterns.sexp @@ -3849,7 +3849,7 @@ "restart test")) (("advice" . - "Validate the sorted document table once when opening the mapping and cache only compact hot metadata such as document ID to length. Keep the much larger term bytes and posting lists mapped. Benchmark before and after with identical queries and report the resident-metadata tradeoff.") + "Validate the sorted document table once when opening the mapping. When the posting format is under your control, store a validated document-table ordinal in each posting and read ID/length metadata directly in O(1), with only a constant-sized current-cursor cache. Otherwise cache the smallest practical hot metadata. Keep term bytes and posting lists mapped, benchmark before and after with identical queries, and report the resident-memory tradeoff.") ("avoid" . "Do not binary-search a mapped document table separately for every posting scored. The logarithmic lookup plus repeated foreign reads can make a memory-mapped query several times slower than the in-memory baseline even when postings themselves are zero-copy.")