Explain PgVector Query Plan
explain_vector_queryRuns read-only EXPLAIN ANALYZE on pre-filtered vector search SQL to detect HNSW index misses and return targeted indexing advice.
Instructions
在只读事务中对带 Pre-filtering 条件的向量检索 SQL 执行 EXPLAIN ANALYZE(FORMAT JSON),解析是否命中 HNSW 索引、过滤淘汰行数与缓存块命中,给出针对性索引调优建议。
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": {
"query": "<query>"
},
"name": "explain_vector_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 用于生成向量并测试执行计划的查询文本 | |
| top_k | No | 执行计划测试 LIMIT 条数 | |
| analyze | No | 是否执行真实 EXPLAIN ANALYZE + BUFFERS | |
| tenant_id | No | Pre-filtering 租户过滤条件 | default |
| doc_status | No | 文档状态过滤条件 | active |
| collection_name | No | 可选:知识库集合名称,用于验证过滤条件下索引命中行为 |