File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
source/reference/operator/aggregation Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -95,10 +95,21 @@ of the desired sub-pipeline output.
95
95
Index Use
96
96
~~~~~~~~~
97
97
98
- The ``$facet`` stage, and its sub-pipelines, cannot make use of indexes,
99
- even if its sub-pipelines use :pipeline:`$match` or if ``$facet`` is
100
- the first stage in the pipeline. The ``$facet`` stage will always
101
- perform a ``COLLSCAN`` during execution.
98
+ Pipeline order determines how the ``$facet`` stage uses indexes.
99
+
100
+ - If the ``$facet`` stage is the first stage in a pipeline, the stage
101
+ will perform a ``COLLSCAN``. The ``$facet`` stage does not make use of
102
+ indexes if it is the first stage in the pipeline.
103
+
104
+ - If the ``$facet`` stage comes later in the pipeline and earlier stages
105
+ have used indexes, ``$facet`` will not trigger a ``COLLSCAN`` during
106
+ execution.
107
+
108
+ For example, :pipeline:`$match` or :pipeline:`$sort` stages that come
109
+ before a ``$facet`` stage can make use of indexes and the ``$facet``
110
+ will not trigger a ``COLLSCAN``.
111
+
112
+ For optimization suggestions, see: :ref:`agg-pipeline-optimization`.
102
113
103
114
Example
104
115
-------
You can’t perform that action at this time.
0 commit comments