# Explain()

Explain은 대부분 데이터베이스 시스템에서 지원을 해주는 기능이다. 사용자의 질의문 (query)을 데이터베이스의 optimizer가 query plan을 통해서 실행하는 것을 보여주는 것이다.&#x20;

* Provides information on the query plan for find() method.&#x20;

* In PyMongo, explain() returns a dictionary. Use a key, ‘executionStats’.

* Example

### explain() in MongoShell

```javascript
db.mycollection.find().explain()
```

### explain() in PyMongo

```python
mycollection.find().explain()
mycollection.find().explain()[‘executionStats’]
```

## Exercise

* Print a query plan using executionStats corresponding to the query that finds writer, Kim.
* Using blog.json

```python
 "executionStats" : {
…
                "executionTimeMillis" : 0,
                "totalKeysExamined" : 0,
                "totalDocsExamined" : 4,
                "nReturned": 1,
                "executionStages": {
                               "stage": "COLLSCAN",
…
```
