From 589a6ab1f0700364f1caf37c046aaf5b8914ab09 Mon Sep 17 00:00:00 2001 From: jason-price-mongodb Date: Tue, 17 Aug 2021 17:31:24 -0700 Subject: [PATCH] DOCS-14453 execution stats inner lookup DOCS-14453 execution stats inner lookup --- source/indexes.txt | 2 + source/reference/explain-results.txt | 69 ++++++++++++++++++++++++++++ source/release-notes/5.0.txt | 7 +++ 3 files changed, 78 insertions(+) diff --git a/source/indexes.txt b/source/indexes.txt index 2d3458a1b5e..eb6a7646d2f 100644 --- a/source/indexes.txt +++ b/source/indexes.txt @@ -295,6 +295,8 @@ page `. .. include:: /includes/extracts/collation-index-type-restrictions.rst +.. _indexes-covered-queries: + Covered Queries --------------- diff --git a/source/reference/explain-results.txt b/source/reference/explain-results.txt index 72ff9c76833..510fa93a6fc 100644 --- a/source/reference/explain-results.txt +++ b/source/reference/explain-results.txt @@ -1,3 +1,5 @@ +.. _explain-results: + =============== Explain Results =============== @@ -605,6 +607,73 @@ execution of the winning plan. In order to include both the winning and rejected plans. The field is present only if ``explain`` runs in ``allPlansExecution`` verbosity mode. +.. _explain-results-lookup: + +Execution Plan Statistics for Query with ``$lookup`` Pipeline Stage +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 5.0 + +The :ref:`explain results ` can include execution +statistics for queries that use a :pipeline:`$lookup` pipeline stage. To +include those execution statistics, you must run the explain operation +in one of these execution verbosity modes: + +- :ref:`executionStats ` +- :ref:`allPlansExecution ` + +The following fields are included in the explain results for a +:pipeline:`$lookup` query: + +.. code-block:: none + :copyable: false + + '$lookup': { + from: , + as: , + localField: , + foreignField: + }, + totalDocsExamined: , + totalKeysExamined: , + collectionScans: , + indexesUsed: [ , , ..., ], + nReturned: , + executionTimeMillisEstimate: + +To see the descriptions for the fields in the ``$lookup`` section, see +the :pipeline:`$lookup` page. + +The other fields are: + +.. data:: explain.totalDocsExamined + + Number of documents examined during the query execution. + +.. data:: explain.totalKeysExamined + + Number of index keys examined. + +.. data:: explain.collectionScans + + Number of times a collection scan occurred during query execution. + During a collection scan, each document in a collection is compared + to the query predicate. Collection scans occur if no appropriate + :ref:`index ` exists that :ref:`covers + ` the query. + +.. data:: explain.indexesUsed + + Array of strings with the names of the indexes used by the query. + +.. data:: explain.nReturned + + Number of documents that match the query condition. + +.. data:: explain.executionTimeMillisEstimate + + Estimated time in milliseconds for the query execution. + .. _serverInfo: ``serverInfo`` diff --git a/source/release-notes/5.0.txt b/source/release-notes/5.0.txt index 9c79cb4a55b..1c524aa2a88 100644 --- a/source/release-notes/5.0.txt +++ b/source/release-notes/5.0.txt @@ -597,6 +597,13 @@ Transactions General Improvements -------------------- +Execution Plan Statistics for Query with ``$lookup`` Pipeline Stage +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +MongoDB 5.0 adds :ref:`execution plan statistics +` for queries that use a :pipeline:`$lookup` +pipeline stage. + Improved Handling of (``$``) and (``.``) in Field Names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~