Automatic optimizations
When you execute a retriever, the planner rewrites your stage list before execution. These transformations are automatic — you don’t configure them:
The retriever is also fetched and optimized once per request, then reused across a batch — so
POST /v1/retrievers/{id}/execute/batch amortizes planning across all queries.
Inspect the plan with explain
POST /v1/retrievers/{retriever_id}/execute/explain returns the optimized execution plan without running the query — per-stage cost and latency estimates, bottlenecks, and exactly which optimizations were applied. Pass hypothetical inputs to see how the plan changes with different parameters.
Example response
estimated_cost_credits and total_credits are legacy fields expressed in the internal ledger unit (1 credit = $0.001). Customer-facing pricing is in dollars — see Billing.How to read it
The
execution_plan reflects the optimized pipeline, not your original stage list. Compare optimization_details.original_stage_count vs optimized_stage_count to see how much the planner collapsed.Profile a run that already happened
explain estimates a plan without running it. To see what an execution actually
did, ask for the profile.
Set "explain": true in an execute body and the response carries explain_plan
alongside the documents: per-stage timings with input and output counts, MVS
execution stats, and the optimizer summary for that run.
Typical workflow
1
Explain before you ship
Run
explain with representative inputs to see estimated cost, bottlenecks, and applied optimizations.2
Act on bottlenecks & suggestions
Reduce
top_k on high-cost searches, add a selective attribute_filter (the optimizer pushes it down), or drop low-selectivity stages.3
Verify in production
Use retriever analytics to confirm real latency and cache-hit rates match the estimate.
Related
- Multi-Stage Retrieval — how stages compose
- Feature Search — the most common bottleneck stage
- Evaluations — measure quality alongside cost
- Best Practices — caching and cost optimization

