Analyze vector search efficiency
analyze_vector_search_efficiencyMeasure pgvector ANN index retrieval quality by sweeping backend-specific search parameters, computing recall@k against exact brute-force results, rank correlation, and latency percentiles to diagnose ranking degradation.
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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"schema": "<schema>",
"table": "<table>",
"column": "<column>",
"id_column": "<id_column>"
},
"name": "analyze_vector_search_efficiency"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| table | Yes | ||
| column | Yes | ||
| metric | No | cosine | |
| schema | Yes | ||
| database | No | Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected. | |
| 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 |