Skip to content

Commit 1c86f64

Browse files
mdb-ashleyAshley Brown
andauthored
DOCS-14409 Clarify multikey index usage (#773)
* Updating multikey sort fact; added glossary entry for blocking sort * Bug fixes * Bug fixes * Bug fixes * Incorporating internal review comments * Removing example * tweaks * Resolving internal review comments * Incorporating review comments Co-authored-by: Ashley Brown <[email protected]>
1 parent 3d62845 commit 1c86f64

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
As a result of changes to sorting behavior on array fields in MongoDB
2-
3.6, when sorting on an array indexed with a
3-
:doc:`multikey index </core/index-multikey/>` the query plan includes
4-
a blocking SORT stage. The new sorting behavior may negatively impact
5-
performance.
2+
4.4, when you sort on an array indexed with a
3+
:ref:`multikey index <index-type-multikey>`, the query plan includes
4+
a :term:`blocking sort` stage, unless:
65

7-
In a blocking SORT, all input must be consumed by the sort step before
8-
it can produce output. In a non-blocking, or *indexed* sort, the
9-
sort step scans the index to produce results in the requested order.
6+
- The index :ref:`boundaries <multikey-index-bounds-intersecting>` for all sort
7+
fields are ``[MinKey, MaxKey]``, *and*
8+
9+
- No boundaries for any multikey-indexed field have the same path prefix as the sort
10+
pattern.

source/reference/glossary.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ Glossary
9393
backup cursor
9494
A :term:`tailable cursor` that points to a list of backup files.
9595
Backup cursors are for internal use only.
96+
97+
blocking sort
98+
A sort that must be performed in memory before output is returned.
99+
Blocking sorts may impact performance for large data sets. Use an
100+
:term:`indexed sort` to avoid a blocking sort.
101+
102+
See :ref:`sort-index-use` for more information on blocking sort
103+
operations.
96104

97105
bounded collection scan
98106
A plan used by the :doc:`query optimizer </core/query-plans>` that
@@ -476,6 +484,12 @@ Glossary
476484
The international date format used by :binary:`~bin.mongosh`
477485
to display dates. The format is: ``YYYY-MM-DD HH:MM.SS.millis``.
478486

487+
indexed sort
488+
A sort in which an index provides the sorted result. Sort operations that
489+
use an index often have better performance than a :term:`blocking sort`.
490+
See :ref:`Use Indexed to Sort Query Results <sorting-with-indexes>` for
491+
more information.
492+
479493
interrupt point
480494
A point in an operation's lifecycle when it can
481495
safely abort. MongoDB only terminates an operation

source/tutorial/sort-results-with-indexes.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Use Indexes to Sort Query Results
1414
:class: singlecol
1515

1616
Since indexes contain ordered records, MongoDB can obtain the results of
17-
a sort from an index with which includes the sort fields. MongoDB *may*
17+
a sort from an index that includes the sort fields. MongoDB *may*
1818
use multiple indexes to support a sort operation *if* the sort uses the
1919
same indexes as the query predicate.
2020

@@ -24,7 +24,7 @@ A blocking sort indicates that MongoDB must consume and process all
2424
input documents to the sort before returning results. Blocking sorts do
2525
not block concurrent operations on the collection or database.
2626

27-
If MongoDB requires using more than 100 megabytes of system memory for
27+
If MongoDB needs more than 100 megabytes of system memory for
2828
the blocking sort operation, MongoDB returns an error *unless* the query
2929
specifies :method:`cursor.allowDiskUse()` (*New in MongoDB 4.4*).
3030
:method:`~cursor.allowDiskUse()` allows MongoDB to use temporary files

0 commit comments

Comments
 (0)