# explain()

*noun*

say it: **“ik-SPLAYN”** **/ɪkˈspleɪn/**

A MongoDB method that reports how a query ran, such as whether it used an index and how many documents it read.

## What does `explain()` do?

`explain()` shows how MongoDB ran a query: which index it used and how many documents it examined, so you can spot missing indexes.

```javascript
db.recipes.find({ category: 'Dessert' }).explain('executionStats')
```

## In a sentence

- “Running **explain()** with "executionStats" counts the documents examined.”
- “**explain()** showed COLLSCAN, so the query had no index to use.”

Level: Freelancer · [More MongoDB terms at this level](https://www.ask-codey.com/glossary?category=mongodb&level=4)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/explain
