Recommend HNSW ef search
recommend_hnsw_ef_searchRecommends the smallest ef_search value that achieves a target recall@k for an HNSW index, by sampling queries, building exact ground truth, and sweeping ef values.
Instructions
Recommend an hnsw.ef_search value for a target recall@k — the actionable companion to analyze_hnsw_recall. Samples sample_queries rows (default 10) as query vectors, builds an exact brute-force top-k ground truth per query, sweeps ef_values (default 16/32/64/128/256) measuring mean recall@k and p50/p95 latency at each, and recommends the smallest value clearing target_recall (default 0.95). Unlike the single-query curve tool, this VERIFIES an HNSW index actually exists on the column (returns has_hnsw_index=false with guidance otherwise — a sweep without one just measures sequential scans). The query row is excluded from its own results. Requires the vector extension. Returns an object with available, has_hnsw_index, index_name, metric, k, target_recall, sample_queries, recommended_ef_search (int or null), detail, and sweep (list of objects with ef_search, mean_recall_at_k, p50_latency_ms, p95_latency_ms, meets_target).
Example: recommend_hnsw_ef_search(schema='public', table='docs', column='embedding', k=10, target_recall=0.95)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| table | Yes | ||
| column | Yes | ||
| metric | No | l2 | |
| schema | Yes | ||
| database | No | Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids. | |
| target_recall | No | ||
| sample_queries | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | Yes | ||
| sweep | Yes | ||
| detail | No | ||
| metric | Yes | ||
| available | Yes | ||
| index_name | Yes | ||
| target_recall | Yes | ||
| has_hnsw_index | Yes | ||
| sample_queries | Yes | ||
| recommended_ef_search | Yes |