@@ -181,8 +181,10 @@ information:
181181 "inputStage" : {
182182 "stage" : <STAGE2>,
183183 ...
184- "nReturned" : 0 ,
184+ "nReturned" : <int> ,
185185 "executionTimeMillisEstimate" : <int>,
186+ "keysExamined" : <int>,
187+ "docsExamined" : <int>,
186188 ...
187189 "inputStage" : {
188190 ...
@@ -219,9 +221,9 @@ information:
219221 .. data:: explain.executionStats.totalKeysExamined
220222
221223 Number of index entries scanned.
222- :data:`~explain.executionStats.totalKeysExamined` corresponds to the
223- ``nscanned`` field returned by ``cursor.explain()`` in earlier
224- versions of MongoDB.
224+ :data:`~explain.executionStats.totalKeysExamined` corresponds to the
225+ ``nscanned`` field returned by ``cursor.explain()`` in
226+ earlier versions of MongoDB.
225227
226228 .. data:: explain.executionStats.totalDocsExamined
227229
@@ -283,6 +285,42 @@ information:
283285 returns more than the specified limit, the ``LIMIT`` stage
284286 will report ``isEOF: 1``, but its underlying ``IXSCAN`` stage
285287 will report ``isEOF: 0``.
288+
289+ .. data:: explain.executionStats.executionStages.inputStage.keysExamined
290+
291+ For query execution stages that scan an index (e.g. IXSCAN),
292+ ``keysExamined`` is the total number of in-bounds and out-of-bounds
293+ keys that are examined in the process of the index scan. If the
294+ index scan consists of a single contiguous range of keys, only
295+ in-bounds keys need to be examined. If the index bounds consists of
296+ several key ranges, the index scan execution process may examine
297+ out-of-bounds keys in order to skip from the end of one range to the
298+ beginning of the next.
299+
300+ Consider the following example, where there is an index of field
301+ ``x`` and the collection contains 100 documents with ``x`` values
302+ 1 through 100:
303+
304+ .. code-block:: javascript
305+
306+ db.keys.find( { x : $in : [ 3, 4, 50, 74, 75, 90 ] } ).explain( "executionStats" )
307+
308+ The query will scan keys ``3`` and ``4``. It will then scan the key
309+ ``5``, detect that it is out-of-bounds, and skip to the next key
310+ ``50``.
311+
312+ Continuing this process, the query scans keys
313+ 3, 4, 5, 50, 51, 74, 75, 76, 90, and 91. Keys
314+ ``5``, ``51``, ``76``, and ``91`` are out-of-bounds keys that are
315+ still examined. The value of ``keysExamined`` is 10.
316+
317+ .. data:: explain.executionStats.executionStages.inputStage.docsExamined
318+
319+ Specifies the number of documents scanned during the
320+ query execution stage.
321+
322+ Present for the ``COLLSCAN`` stage, as well as for stages that
323+ retrieve documents from the collection (e.g. ``FETCH``)
286324
287325 .. data:: explain.executionStats.allPlansExecution
288326
0 commit comments