In pgvector approximate searches, ordinary filters are commonly applied as candidates are scanned. A selective tenant, category, or date predicate can therefore leave fewer than the requested top-k rows. Increase search effort, enable iterative scans where supported, add relational indexes, or change physical design with partial indexes or partitioning—then measure recall and latency.
If an HNSW scan visits 40 candidates and only 10% pass the filter, roughly four may survive; the exact number depends on data and graph traversal. Raising hnsw.ef_search may help. Current pgvector versions also support iterative scans that continue exploring until enough rows are found or a safety limit is reached.
strict_order preserves exact distance ordering among found candidates. relaxed_order can improve recall/speed but may need materialization and reordering when strict presentation matters. IVFFlat has corresponding iterative-scan and maximum-probe settings. Confirm setting names and defaults for the installed version.
Partial-index predicates must match query semantics and remain maintainable.
Build queries at 90%, 10%, 1%, and 0.1% selectivity. For each, compare exact results with ANN using default, higher effort, strict iterative, and relaxed iterative settings. Record result count, recall@k, latency, buffers, and plan. Include tenants with few rows.
Analyze this filtered pgvector workload [queries, selectivity histogram, index DDL]. Propose B-tree, search-effort, iterative-scan, partial-index, and partition experiments. Include exact recall, returned-count, latency, and maintenance tradeoffs for every selectivity slice.
Verification contract: No design passes unless it meets minimum returned-count and recall objectives for the rarest authorized slice.