Get a detailed execution plan for a retriever without actually executing it. Similar to MongoDB’s explain plan or 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:
Key Features:
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:
Example Response:
{
"retriever_id": "ret_abc123",
"retriever_name": "product_search",
"execution_plan": [
{
"stage_index": 0,
"stage_name": "attribute_filter",
"stage_type": "filter",
"estimated_input": 10000,
"estimated_output": 5000,
"estimated_efficiency": 0.5,
"estimated_cost_credits": 0.01,
"estimated_duration_ms": 20,
"cache_likely": true,
"optimization_notes": ["Pushed down from stage 2"],
"warnings": []
},
{
"stage_index": 1,
"stage_name": "semantic_search",
"stage_type": "filter",
"estimated_input": 5000,
"estimated_output": 100,
"estimated_efficiency": 0.02,
"estimated_cost_credits": 0.5,
"estimated_duration_ms": 200,
"cache_likely": false,
"optimization_notes": [],
"warnings": ["High cost stage - consider reducing limit"]
}
],
"estimated_cost": {
"total_credits": 0.51,
"total_duration_ms": 220
},
"bottleneck_stages": ["semantic_search"],
"optimization_applied": true,
"optimization_details": {
"original_stage_count": 3,
"optimized_stage_count": 2,
"optimization_time_ms": 8.2,
"stage_reduction_pct": 33.3,
"decisions": [
{
"rule_type": "push_down_filters",
"applied": true,
"reason": "Moved attribute_filter before semantic_search to reduce search scope"
}
]
},
"optimization_suggestions": [
{
"type": "reduce_limit",
"stage": "semantic_search",
"message": "Consider reducing limit to improve latency"
}
]
}
REQUIRED: Bearer token authentication using your API key. Format: 'Bearer sk_xxxxxxxxxxxxx'. You can create API keys in the Mixpeek dashboard under Organization Settings.
REQUIRED: Namespace identifier for scoping this request. All resources (collections, buckets, taxonomies, etc.) are scoped to a namespace. You can provide either the namespace name or namespace ID. Format: ns_xxxxxxxxxxxxx (ID) or a custom name like 'my-namespace'
Retriever ID or name to explain. The execution plan will show the OPTIMIZED version after automatic transformations.
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.
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:
Examples:
Note: Inputs are for estimation only. No actual search is performed.
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
Unique identifier of the retriever being explained. REQUIRED.
Human-readable name of the retriever. 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.
x >= 0Ordered 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).
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).
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).
Optimization level applied by the optimizer. Values: 'none' (no optimization), 'mvp' (basic optimizations), 'advanced' (all optimizations). REQUIRED.
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.
Detailed breakdown of optimization transformations applied. Only present when optimization_applied=true.
Fields:
Each decision contains:
Common rule types:
OPTIONAL (null when optimization_applied=false).
{
"decisions": [
{
"applied": true,
"reason": "Moved attribute_filter before semantic_search to reduce search scope by 50%",
"rule_type": "push_down_filters",
"stages_after": 5,
"stages_before": 5
},
{
"applied": true,
"reason": "Merged group_by into feature_filter for database-level grouping (10x faster)",
"rule_type": "group_by_push_down",
"stages_after": 3,
"stages_before": 5
}
],
"optimization_time_ms": 8.2,
"optimized_stage_count": 3,
"original_stage_count": 5,
"stage_reduction_pct": 40
}