Skip to content

Commit 7d6db96

Browse files
author
Dave Cuthbert
authored
DOCSP-26605 facets and indexes (#2387)
* DOCSP-26605 facets and indexes * Review feedback * Review feedback
1 parent 0fbbe45 commit 7d6db96

File tree

1 file changed

+15
-4
lines changed
  • source/reference/operator/aggregation

1 file changed

+15
-4
lines changed

source/reference/operator/aggregation/facet.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,21 @@ of the desired sub-pipeline output.
9595
Index Use
9696
~~~~~~~~~
9797

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`.
102113

103114
Example
104115
-------

0 commit comments

Comments
 (0)