The slot-based query engine is MongoDB’s execution engine for representing intermediate values in slots. It generally uses less CPU and memory and often performs better than the classic query engine. MongoDB selects the engine automatically; applications cannot choose it manually. section 7.1.1 section 7.8
Use query diagnostics to identify the selected engine and investigate its performance:
- Run db.collection.explain() or cursor.explain() with queryPlanner, executionStats, or allPlansExecution verbosity. section 7.1.1
- Look for explain.queryPlanner.winningPlan.slotBasedPlan in explain output; its presence identifies slot-based execution. section 7.1.1
- Check logs for queryFramework: "sbe" or queryFramework: "classic" when explain output is unavailable. section 7.1.1
- Expect common slot-based execution for aggregation pipelines containing $group or $lookup, while unsupported queries use the classic engine. section 7.1.1
Identifying slot-based execution
Run a query with explain("executionStats"), then inspect explain.queryPlanner.winningPlan. A winning plan containing slotBasedPlan indicates the slot-based engine; executionStats also reports returned documents, execution time, examined keys, and examined documents.
