@@ -29,7 +29,7 @@ understanding of:
29
29
30
30
The best overall strategy for designing indexes is to profile a variety
31
31
of index configurations with data sets similar to the ones you'll be
32
- running in production and to see which configurations perform best.
32
+ running in production to see which configurations perform best.
33
33
34
34
MongoDB can only use *one* index to support any given
35
35
operation. However, each clause of an :operator:`$or` query can use
@@ -41,14 +41,14 @@ Create Indexes to Support Your Queries
41
41
--------------------------------------
42
42
43
43
If you only ever query on a single key in a given collection, then you need
44
- create just one single-key index for that collection. For example, you
44
+ to create just one single-key index for that collection. For example, you
45
45
might create an index on ``category`` in the ``product`` collection:
46
46
47
47
.. code-block:: javascript
48
48
49
49
db.products.ensureIndex( { "category": 1 } )
50
50
51
- However, if you sometimes query on only one key but and at other times
51
+ However, if you sometimes query on only one key and at other times
52
52
query on that key combined with a second key, then creating a
53
53
:ref:`compound index <index-type-compound>` is more efficient. MongoDB
54
54
will use the compound index for both queries. For example, you might
@@ -122,9 +122,9 @@ part of an index. They are "covered queries" because an index "covers" the query
122
122
MongoDB can fulfill the query by using *only* the index. MongoDB need
123
123
not scan documents from the database.
124
124
125
- Querying *only* the index is much faster than querying documents.
126
- Indexes keys are typically smaller than the documents they catalog, and indexes are
127
- typically stored in RAM or located sequentially on disk.
125
+ Querying *only* the index is much faster than querying documents. Index
126
+ keys are typically smaller than the documents they catalog, and indexes
127
+ are typically stored in RAM or located sequentially on disk.
128
128
129
129
Mongod automatically uses a covered query when possible. To ensure use
130
130
of a covered query, create an index that includes all the fields listed
@@ -135,7 +135,7 @@ explicitly exclude the ``_id`` field from the result set, unless the
135
135
index includes ``_id``.
136
136
137
137
MongoDB cannot use a covered query if any of the indexed fields in any
138
- of the documents in the collection include an array. If an indexed field
138
+ of the documents in the collection includes an array. If an indexed field
139
139
is an array, the index becomes a :ref:`multi-key index
140
140
<index-type-multikey>` index and cannot support a covered query.
141
141
@@ -197,10 +197,10 @@ are equality matches.
197
197
198
198
.. note::
199
199
200
- When the :method:`sort() <cursor.sort()>` method performs an
201
- in-memory sort operation without the use of an index, the operation
202
- is significantly slower than for operations that use an index, and
203
- the operation aborts when it consumes 32 megabytes of memory.
200
+ For in-memory sorts that do not use an index, the :method:`sort()
201
+ <cursor. sort()>` operation is significantly slower. The
202
+ :method:`~cursor.sort()` operation will abort when it uses 32
203
+ megabytes of memory.
204
204
205
205
.. _indexes-ensure-indexes-fit-ram:
206
206
@@ -226,7 +226,7 @@ available but also must have RAM available for the rest of the
226
226
227
227
If you have and use multiple collections, you must consider the size
228
228
of all indexes on all collections. The indexes and the working set must be able to
229
- fit RAM at the same time.
229
+ fit in RAM at the same time.
230
230
231
231
There are some limited cases where indexes do not need
232
232
to fit in RAM. See :ref:`indexing-right-handed`.
@@ -337,8 +337,8 @@ Consider Performance when Creating Indexes for Write-heavy Applications
337
337
If your application is write-heavy, then be careful when creating new
338
338
indexes, since each additional index with impose a
339
339
write-performance penalty. In general, don't be careless about adding
340
- indexes. Add indexes complement your queries. Always have
341
- a good reason for adding a new index, and make sure you've benchmarked
340
+ indexes. Add indexes to complement your queries. Always have
341
+ a good reason for adding a new index, and be sure to benchmark
342
342
alternative strategies.
343
343
344
344
Consider Insert Throughput
@@ -347,17 +347,16 @@ Consider Insert Throughput
347
347
.. todo:: insert link to /source/core/write-operations when that page is complete.
348
348
Do we want to link to write concern? -bg
349
349
350
- MongoDB must update *all* indexes associated with a collection after every
351
- insert, update, or delete operation. For update operations, if the updated document
352
- does not move to a new location, then only the modified, MongoDB only needs
353
- to update the updated fields in the index.
354
- Therefore, every index on a
355
- collection adds some amount of overhead to these write operations. In almost
356
- every case, the performance gains that indexes realize for read
350
+ MongoDB must update *all* indexes associated with a collection after
351
+ every insert, update, or delete operation. For update operations, if
352
+ the updated document does not move to a new location, then MongoDB only
353
+ modifies the updated fields in the index. Therefore, every index on a
354
+ collection adds some amount of overhead to these write operations. In
355
+ almost every case, the performance gains that indexes realize for read
357
356
operations are worth the insertion penalty. However, in some cases:
358
357
359
358
- An index to support an infrequent query might incur more
360
- insert-related costs than saved read-time.
359
+ insert-related costs than savings in read-time.
361
360
362
361
.. todo:: How do you determine if the above is the case?
363
362
Empirically.
@@ -371,5 +370,5 @@ operations are worth the insertion penalty. However, in some cases:
371
370
372
371
- If your indexes and queries are not sufficiently :ref:`selective
373
372
<index-selectivity>`, the speed improvements for query operations
374
- might not offset the costs of maintaining an index. For more
373
+ may not offset the costs of maintaining an index. For more
375
374
information see :ref:`index-selectivity`.
0 commit comments