preflight_vector_search
Check pgvector similarity search cost before execution. Flags brute-force scans, oversized top_k, unbounded searches, and filter recall loss using EXPLAIN only.
Instructions
Before running a VECTOR SIMILARITY SEARCH (pgvector: ORDER BY embedding <-> $1 LIMIT k, cosine <=>, inner-product <#>), check its cost WITHOUT
running it — for any RAG / semantic-search / nearest-neighbour query you
generate. Catches the vector traps a plain SQL check misses: brute-force
scan with no HNSW/IVFFlat index (FULL_VECTOR_SCAN), top_k too large
(TOP_K_TOO_LARGE), unbounded search (UNBOUNDED_VECTOR_SEARCH), and metadata-
filter/ANN recall loss (VECTOR_FILTER_INTERACTION). EXPLAIN only. Pass
target= in a multi-DB setup; the target should be a pgvector engine.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| target | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |