@@ -7,34 +7,37 @@ Index Overview
7
7
Synopsis
8
8
--------
9
9
10
- Indexes are an internal representation of the documents in your
11
- database organized so that MongoDB can use them to quickly locate
12
- documents and fulfill queries very efficiently. Fundamentally, indexes
10
+ An index is a data structure that allows you to quickly locate documents
11
+ based on the values stored in certain specified fields. Fundamentally, indexes
13
12
in MongoDB are similar to indexes in other database systems. MongoDB
14
13
supports indexes on any field or sub-field contained in documents
15
14
within a MongoDB collection. Consider the following core features of
16
15
indexes:
17
16
18
17
- MongoDB defines indexes on a per-:term:`collection` level.
19
18
20
- - Every query (including update operations,) can use one and only one
21
- index. The query optimizer determines, empirically, the best query
22
- plan and indexes to use on a specific query, but can be overridden
23
- using the :func:`cursor.hint()` method. However, :ref:`compound
24
- indexes <index-type-compound>` make it possible to include multiple
25
- fields in a single index.
26
-
27
19
- Indexes often dramatically increase the performance of queries;
28
20
however, each index creates a slight overhead for every write
29
21
operation.
30
22
23
+ - Every query (including update operations) use one and only one
24
+ index. The query optimizer determines which index to use
25
+ empirically, by occasionally running multiple query plans,
26
+ and tracking the most performant index for each query type.
27
+ The query optimizer's choice can be overridden
28
+ using the :func:`cursor.hint()` method.
29
+
30
+ - Indexes can be created over a single field, or multiple fields using a
31
+ :ref:`compound index <index-type-compound>`.
32
+
31
33
- Queries that are "covered" by the index return more quickly
32
- than documents that have to scan many individual documents.
34
+ than queries that have to scan many individual documents. An index is
35
+ considered to "cover" a query if all the data that the query must return
36
+ is stored in within the keys of the index.
33
37
34
- - By using queries with good index coverage, it possible for MongoDB
35
- to only store the index itself and the most often used documents in
36
- memory, which can maximize database capacity, performance and
37
- throughput.
38
+ - Using queries with good index coverage will reduce the number of full
39
+ documents that MongoDB needs to store in memory, thus maximizing database
40
+ performance and throughput.
38
41
39
42
Continue reading for a complete overview of indexes in MongoDB,
40
43
including the :ref:`types of indexes <index-types>`, basic
0 commit comments