> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Slot-Based Query Execution Engine

**New in version 5.1**

To find and return query results, MongoDB uses one of the following query engines:

- The classic query engine

- The slot-based query execution engine, which is available for some queries starting in MongoDB 5.1.

The slot-based query execution engine uses a "slot-based" model to avoid materialization of intermediate results during query runtime, which allows for more efficient execution.

MongoDB automatically selects the engine to execute the query. In MongoDB versions earlier than 8.0, you cannot manually specify an engine for a particular query. Starting in MongoDB 8.0, you can use query settings to specify an engine for queries. For details, see [`setQuerySettings`.](https://www.mongodb.com/docs/manual/reference/command/setquerysettings.md#mongodb-dbcommand-dbcmd.setQuerySettings)

MongoDB can use the slot-based query execution engine for a subset of queries provided certain conditions are met. In most cases, the slot-based execution engine provides improved performance and lower CPU and memory costs compared to the classic query engine.

MongoDB uses the classic engine for queries that are ineligible for the slot-based query execution engine.

## Eligible Queries for the Slot-Based Execution Engine

MongoDB determines eligibility for using the slot-based execution engine on a per-query basis, and considers support for each operator and expressions present in the query. For example, two common pipelines that use slot-based execution engine are aggregations with [`$group`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/group.md#mongodb-pipeline-pipe.-group) or [`$lookup`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup.md#mongodb-pipeline-pipe.-lookup) stages. However, support for the slot-based execution engine is version specific and actively changing.

To see whether your query used the slot-based execution engine, refer to the [Determine which Query Engine was Used](https://www.mongodb.com/docs/manual/reference/sbe.md#std-label-sbe-determine-query-engine) section.

**Important:**

MongoDB automatically disables slot-based execution engine on collections with an index with a hashed path [prefix](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-compound.md#std-label-compound-index-prefix) of a non-hashed path, where both paths are in the index.

### Block Processing

Starting in version 8.0, MongoDB may execute certain time series queries using block processing. This performance improvement processes queries in "blocks" of data, rather than individual values. Block processing improves query execution speed and throughput when working with time series collections.

To learn more, see [Querying Time Series Data.](https://www.mongodb.com/docs/manual/core/timeseries/timeseries-querying.md#std-label-timeseries-querying-block-processing)

## Determine which Query Engine was Used

There are a few ways to determine whether the classic engine or the slot-based execution engine was used to execute a query.

### Check Query Explain Results

The explain results for a query differ based on which query engine was used. For example, explain results for queries executed using the slot-based execution engine include the [`explain.queryPlanner.winningPlan.slotBasedPlan`](https://www.mongodb.com/docs/manual/reference/explain-results.md#mongodb-data-explain.queryPlanner.winningPlan.slotBasedPlan) field.

For more information about the differences in explain results between query engines, see [Explain Output Structure.](https://www.mongodb.com/docs/manual/reference/explain-results.md#std-label-explain-output-structure)

### Check Slow Query Logs

Slow operation log messages include a `queryFramework` field that indicates which query engine executed the query:

- `queryFramework: "classic"` indicates that the classic engine executed the query.

- `queryFramework: "sbe"` indicates that the slot-based query execution engine executed the query.

To see an example log message for a query that used the slot-based execution engine, see [Slow Operation.](https://www.mongodb.com/docs/manual/reference/log-messages.md#std-label-log-message-json-examples-slow-op)

Starting in MongoDB 9.0, slow query logs include a `planRankerMethod` field that indicates which [query plan ranking mechanism](https://www.mongodb.com/docs/manual/core/query-plans.md#std-label-query-plan-options) selected the winning plan:

- `planRankerMethod: "cbr"` indicates that the query planner chose the cost-based ranker.

- `planRankerMethod: "mp"` indicates that the query planner chose the multi-planner.
