Skip to content

DOCS-11338 - Add multikey index sort limitation to tutorial and manual pages #3246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions source/core/index-multikey.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ an array; you do not need to explicitly specify the multikey type.

.. versionchanged:: 3.4

*For the WiredTiger and In-Memory storage engines only*,
*For the WiredTiger and In-Memory storage engines only*,

Starting in MongoDB 3.4, for multikey indexes created using MongoDB
3.4 or later, MongoDB keeps track of which indexed field or fields
Expand Down Expand Up @@ -104,7 +104,7 @@ array. That is:
A compound multikey index ``{ a: 1, b: 1 }`` is permissible since for
each document, only one field indexed by the compound multikey index
is an array; i.e. no document contains array values for both ``a``
and ``b`` fields.
and ``b`` fields.

However, after creating the compound multikey index, if you attempt
to insert a document where both ``a`` and ``b`` fields are arrays,
Expand All @@ -131,6 +131,11 @@ For an example, see :ref:`multikey-embedded-documents`.

- :ref:`index-unique-index`

Sorting
~~~~~~~

.. include:: /includes/fact-multikey-index-sort-limitation.rst

Shard Keys
~~~~~~~~~~

Expand Down
9 changes: 9 additions & 0 deletions source/includes/fact-multikey-index-sort-limitation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
As a result of changes to sorting behavior on array fields in MongoDB
3.6, when sorting on an array indexed with a
:doc:`multikey index </core/index-multikey/>` the query plan includes
a blocking SORT stage. The new sorting behavior may negatively impact
performance.

In a blocking SORT, all input must be consumed by the sort step before
it can produce output. In a non-blocking, or *indexed* sort, the
sort step scans the index to produce results in the requested order.
8 changes: 2 additions & 6 deletions source/release-notes/3.6-compatibility.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,9 @@ account when choosing the array element which will act as the
As a result of this change, applications that currently sort by an
array field may experience a different sort order.

.. note ::
.. note::

As of version 3.6, the query engine cannot use a
:doc:`multikey index </core/index-multikey/>` to provide a
non-blocking sort by an array field. If you try to sort in this
manner, the query plan will include a blocking SORT stage, which
may negatively impact performance.
.. include:: /includes/fact-multikey-index-sort-limitation.rst

.. _3.6-find-method-sort:

Expand Down
4 changes: 4 additions & 0 deletions source/tutorial/sort-results-with-indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ memory. Sort operations that use an index often have better performance
than those that do not use an index. In addition, sort operations that
do *not* use an index will abort when they use 32 megabytes of memory.

.. note::

.. include:: /includes/fact-multikey-index-sort-limitation.rst

.. _sort-results-single-field:

Sort with a Single Field Index
Expand Down