Skip to content

DOCSP-13698 Index Intersection is rarely chosen by the query planner #4821

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
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
25 changes: 22 additions & 3 deletions source/core/index-intersection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,29 @@ Index Intersection
:depth: 1
:class: singlecol

.. important::

This page documents cases where the :doc:`query optimizer
</core/query-plans>` **may** be able to use index intersection.

In practice, the :doc:`query optimizer </core/query-plans>` rarely
selects plans that use index intersection.

Hash-based index intersection is disabled by default and sort-based
index intersection is disfavored in plan selection. The optimizer
behaves in this fashion in order to prevent bad plan selection.

Schema designs should not rely on index intersection. Instead,
:doc:`compound indexes </core/index-compound>` should be used.

Future improvements to the query optimizer may allow the system to
better identify cases where an index intersection plan would be
beneficial.

MongoDB can use the intersection of multiple indexes to fulfill
queries. In general, each index intersection
involves two indexes; however, MongoDB can employ multiple/nested index
intersections to resolve a query.
queries. In general, each index intersection involves two indexes;
however, MongoDB can employ multiple/nested index intersections to
resolve a query.

To illustrate index intersection, consider a collection ``orders`` that
has the following indexes:
Expand Down