Analyze vector search efficiency
analyze_vector_search_efficiencyEvaluate ANN index retrieval quality by sweeping search knobs, measuring recall@k, latency, and rank correlation against brute-force exact search. Identify baseline recall issues or ineffective pruning to tune vector search performance.
Instructions
Cross-backend retrieval-quality report for a pgvector or pg_turboquant ANN index. Detects the backend (HNSW / IVFFlat / turboquant), sweeps the matching per-backend knob (ef_search / probes / candidate_limit) across a multiplier curve, computes recall@k vs a brute-force exact baseline, Spearman + Kendall rank correlation, per-query p50/p95 wall-clock latency, and (for turboquant) the page-pruning ratio from tq_last_scan_stats. Emits findings: baseline_recall_low (CRITICAL), rerank_lift_flat / rerank_lift_steep / ranking_degraded / pruning_ineffective (WARNING). Burns sample_size x (1 + len(candidate_multipliers)) queries; ad-hoc diagnostic, not a cron tool. Requires the vector extension; turboquant-arm metrics require pg_turboquant.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| table | Yes | ||
| column | Yes | ||
| metric | No | cosine | |
| 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. | |
| id_column | Yes | ||
| index_name | No | ||
| sample_size | No | ||
| candidate_multipliers | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | Yes | ||
| table | Yes | ||
| column | Yes | ||
| metric | Yes | ||
| schema | Yes | ||
| backend | Yes | ||
| findings | Yes | ||
| index_name | Yes | ||
| sample_size | Yes | ||
| rerank_lift_curve | Yes | ||
| recall_at_k_baseline | Yes | ||
| pages_pruned_ratio_p50 | Yes | ||
| score_rank_correlation_kendall | Yes | ||
| score_rank_correlation_spearman | Yes |