Skip to content

Commit 0951346

Browse files
committed
DOCSP-11302 correct compound index stock vs location
1 parent 507e312 commit 0951346

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

source/core/index-compound.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,23 @@ the following fields:
155155
- the ``item`` field *and* the ``location`` field,
156156
- the ``item`` field *and* the ``location`` field *and* the ``stock`` field.
157157

158-
MongoDB can also use the index to support a query on ``item`` and
159-
``stock`` fields since ``item`` field corresponds to a prefix. However,
160-
the index would not be as efficient in supporting the query as would be
161-
an index on only ``item`` and ``stock``.
162-
163-
However, MongoDB cannot use the index to support queries that include
164-
the following fields since without the ``item`` field, none of the
165-
listed fields correspond to a prefix index:
158+
MongoDB can also use the index to support a query on the ``item`` and
159+
``stock`` fields, since the ``item`` field corresponds to a prefix.
160+
However, in this case the index would not be as efficient in supporting
161+
the query as it would be if the index were on only ``item`` and
162+
``stock``. Index fields are parsed in order; if a query omits a
163+
particular index prefix, it is unable to make use of any index fields
164+
that follow that prefix.
165+
166+
Since a query on ``item`` and ``stock`` omits the ``location`` index
167+
prefix, it cannot use the ``stock`` index field which follows
168+
``location``. Only the ``item`` field in the index can support this
169+
query. See :ref:`create-indexes-to-support-queries` for
170+
more information.
171+
172+
MongoDB cannot use the index to support queries that include the
173+
following fields since without the ``item`` field, none of the listed
174+
fields correspond to a prefix index:
166175

167176
- the ``location`` field,
168177

0 commit comments

Comments
 (0)