Get a detailed execution plan for a retriever without actually executing it. Similar to SQL’s EXPLAIN command, this endpoint helps you understand performance characteristics, identify bottlenecks, estimate costs, and troubleshoot retrieval issues before running expensive queries.
What This Returns:
Stage-by-stage execution plan (AFTER automatic optimizations)
Estimated costs (credits + time per stage)
Document flow projections (input/output counts per stage)
Optimization details (transformations applied by the optimizer)
Performance warnings and improvement suggestions
Key Features:
Cost Estimation: See how many credits and milliseconds each stage will consume
Bottleneck Detection: Identify which stages dominate execution time
Optimization Transparency: Understand how your pipeline was optimized
Cache Analysis: See which stages are likely to hit cache
Accuracy Troubleshooting: Analyze stage efficiency and document flow
Latency Analysis: Break down estimated duration by stage
Important: The execution_plan shows OPTIMIZED stages (after automatic transformations like filter push-down, stage fusion, and grouping optimization). Check optimization_details to understand what changed from your original configuration.
Use Cases:
Debug slow retrievers by identifying bottleneck stages
Estimate costs before running expensive queries
Understand how the optimizer transformed your pipeline
Troubleshoot accuracy issues by analyzing stage selectivity
Retrievers: A retriever is a saved search pipeline over one or more collections in a namespace. It runs its stages in order, such as feature search, filtering and reranking, and returns matching documents. input_schema defines the inputs each execution accepts. Read the guide.
Mixpeek API key, sent as Authorization: Bearer mxp_sk_.... Create one in Studio under Settings → API Keys, or with an admin key via POST /v1/organizations/users/{user_email}/api-keys. A missing, malformed, unknown, revoked, inactive or expired key returns 401; a key without the permission, scope or plan an operation needs returns 403.
X-Namespace
string
header
required
Namespace id (ns_...), not the namespace name. This scopes the request rather than authenticating it, and it is required on every operation marked x-mixpeek-namespace-scoped.
Path Parameters
retriever_id
string
required
Retriever ID or name to explain. The execution plan will show the OPTIMIZED version after automatic transformations.
Body
application/json
Keys this body does not declare are refused with 422 extra_forbidden naming the accepted keys (since 2026-11-02).
Optional hypothetical inputs for estimation. Provide sample inputs to see how the plan changes with different parameters (e.g., different top_k values, query complexity, filter combinations). If not provided, uses default/representative values.
inputs
Inputs · object
Hypothetical inputs for tailored execution plan estimation. These values are used to analyze stage behavior and estimate costs.
NOT REQUIRED - if omitted, default/representative values are used.
Common inputs:
'query': Search query text (for semantic search stages)
'top_k': Number of results to return (affects search scope)
Filter parameters: Category, price range, etc.
Examples:
{'query': 'laptop'} - Simple text query
{'query': 'laptop', 'top_k': 100} - Query with custom limit
{'query': 'laptop', 'category': 'electronics', 'price_max': 1000} - Query with filters
Note: Inputs are for estimation only. No actual search is performed.
Also check whether the retriever can answer the question before it runs: each concept in question (or, without it, the string inputs) is matched against the retriever's inputs, the field paths of its collections, their declared descriptions and values, and the values seen in a sample of up to 200 documents per collection. Free: no model call and no search.
question
string | null
The question to check with check_answerability. Defaults to the string inputs joined.
Response
Detailed execution plan with stage-by-stage cost estimates, optimization details, bottleneck identification, and performance insights. Use this to troubleshoot slow queries, estimate costs, and understand optimizer transformations.
Execution plan analysis for a retriever.
Provides comprehensive diagnostics about retriever execution characteristics
without actually running the query. Similar to MongoDB's explain plan or SQL's
EXPLAIN command, this helps troubleshoot performance, estimate costs, and
understand optimizer behavior.
Use Cases:
- Identify bottleneck stages before execution
- Estimate costs for budget planning
- Debug slow retrievers by analyzing stage efficiency
- Understand optimizer transformations
- Compare different retriever configurations
- Troubleshoot accuracy issues via document flow analysis
retriever_id
string
required
Unique identifier of the retriever being explained. REQUIRED.
Examples:
"ret_abc123"
"ret_product_search_v2"
retriever_name
string
required
Human-readable name of the retriever. REQUIRED.
Examples:
"product_search"
"customer_lookup"
estimated_cost
Estimated Cost · object
required
Estimated total cost breakdown for executing this retriever. Contains: 'total_credits' (credit cost), 'total_duration_ms' (latency). Sum of all stage costs. Use for budget planning. REQUIRED.
Total number of stages in the optimized execution plan. This may differ from your original stage count if optimizations were applied. Compare with optimization_details.original_stage_count to see reduction. REQUIRED.
Required range: x >= 0
Examples:
2
5
10
execution_plan
ExplainStagePlan · object[]
Ordered list of stage execution plans showing the OPTIMIZED pipeline. Each entry shows cost, latency, document flow, and warnings for one stage. Stages execute in this order. REQUIRED (may be empty for invalid retrievers).
Show child attributes
optimization_suggestions
Optimization Suggestions · object[]
Actionable suggestions for improving retriever performance. Each suggestion includes: 'type' (suggestion category), 'stage' (affected stage name), 'message' (human-readable description). Common types: 'reduce_limit', 'add_filter', 'reorder_stages', 'enable_cache'. OPTIONAL (empty if no suggestions).
Example:
[ { "message": "Consider reducing limit from 1000 to 100 to improve latency", "stage": "semantic_search", "type": "reduce_limit" }, { "message": "Add attribute filter before this expensive stage", "stage": "llm_quality_filter", "type": "add_filter" } ]
bottleneck_stages
string[]
Names of stages expected to dominate execution time. Includes stages with duration >= 80%% of the slowest stage. Focus optimization efforts on these stages. OPTIONAL (empty if all stages have similar duration).
Examples:
["semantic_search"]
["llm_quality_filter", "rerank"]
answerability
RetrieverAnswerability · object | null
Present with check_answerability: true: whether the question's concepts name anything this retriever reads, and the closest name for each one that does not. Checked from names only; nothing runs.
Show child attributes
optimization_level
string
default:mvp
Optimization level applied by the optimizer. Values: 'none' (no optimization), 'mvp' (basic optimizations), 'advanced' (all optimizations). REQUIRED.
Examples:
"none"
"mvp"
"advanced"
optimization_applied
boolean
default:false
Whether automatic pipeline optimizations were applied. When true, execution_plan shows OPTIMIZED stages (after transformations like filter push-down, stage fusion, grouping optimization). When false, execution_plan matches your original configuration. Check optimization_details to see what changed. REQUIRED.
optimization_details
Optimization Details · object | null
Detailed breakdown of optimization transformations applied. Only present when optimization_applied=true.
Fields:
original_stage_count: Stage count before optimization
optimized_stage_count: Stage count after optimization
optimization_time_ms: Time spent on optimization (typically <100ms)
stage_reduction_pct: Percentage reduction in stage count
decisions: Array of optimization decisions
Each decision contains:
rule_type: Optimization rule that fired
applied: Whether the rule was applied
reason: Human-readable explanation
stages_before/after: Stage counts before/after this rule
Common rule types:
push_down_filters: Move filters earlier to reduce downstream work
group_by_push_down: Push grouping to database layer (10-100x faster)