@@ -40,6 +40,8 @@ of the ``people`` collection:
4040
4141 db.people.ensureIndex( { phone-number: 1 } )
4242
43+ TODO: you need ""s around phone-number, otherwise it's invalid JS (phone minus number).
44+
4345To create a :ref:`compound index <index-type-compound>`, use an
4446operation that resembles the following prototype:
4547
@@ -60,13 +62,17 @@ collection:
6062 To build indexes for a :term:`replica set`, before version 2.2,
6163 see :ref:`index-building-replica-sets`.
6264
65+ TODO: I don't think anything changed about replica set index builds for 2.2...
66+
6367.. [#ensure] As the name suggests, :func:`ensureIndex() <db.collection.ensureIndex()>`
6468 only creates an index if an index of the same specification does
6569 not already exist.
6670
6771Sparse
6872``````
6973
74+ TODO: Sparse? Maybe "Types of Indexes->Sparse"?
75+
7076To create a :ref:`sparse index <index-type-sparse>` on a field, use an
7177operation that resembles the following prototype:
7278
@@ -87,6 +93,12 @@ without the ``twitter_name`` field.
8793
8894 MongoDB cannot create sparse compound indexes.
8995
96+ TODO: is this true? I thought that it could.
97+
98+ TODO: Is there more doc on spare indexes somewhere? Seems like this is missing
99+ some info like getting different results back when the index is used, null
100+ counts as existing, etc.
101+
90102Unique
91103``````
92104
@@ -105,10 +117,14 @@ records for the same legal entity:
105117
106118 db.accounts.ensureIndex( { tax-id: 1 }, { unique: true } )
107119
120+ TODO: tax-id should be in ""s.
121+
108122The :ref:`_id index <index-type-primary>` is a unique index. In some
109123situations you may want to use the ``_id`` field for these primary
110124data rather than using a unique index on another field.
111125
126+ TODO: "for these primary data"?
127+
112128In many situations you will want to combine the ``unique`` constraint
113129with the ``sparse`` option. When MongoDB indexes a field, if a
114130document does not have a value for a field, the index entry for that
@@ -141,6 +157,8 @@ as in the following example:
141157
142158 db.accounts.dropIndex( { tax-id: 1 } )
143159
160+ TODO: ""s!
161+
144162This will remove the index on the ``tax-id`` field in the ``accounts``
145163collection. The shell provides the following document after completing
146164the operation:
@@ -203,6 +221,12 @@ for this operation.
203221 To rebuild indexes for a :term:`replica set`, before version 2.2,
204222 see :ref:`index-rebuilding-replica-sets`.
205223
224+ TODO: again, this probably isn't different in 2.2
225+
226+ TODO: one thing that I would appreciate you mentioning is that some drivers may
227+ create indexes like {a : NumberLong(1)} _which is fine_ and doesn't break
228+ anything so stop complaining about it.
229+
206230Special Creation Options
207231~~~~~~~~~~~~~~~~~~~~~~~~
208232
@@ -211,6 +235,8 @@ Special Creation Options
211235 TTL collections use a special ``expire`` index option. See
212236 :doc:`/tutorial/expire-data` for more information.
213237
238+ TODO: Are 2d indexes getting a mention?
239+
214240Background
215241``````````
216242
@@ -222,11 +248,25 @@ prototype invocation of :func:`db.collection.ensureIndex()`:
222248
223249 db.collection.ensureIndex( { a: 1 }, { background: true } )
224250
251+ TODO: what does it mean to build an index in the background? You might want to
252+ mention:
253+ * performance implications
254+ * that this type of index build can be killed
255+ * that this blocks the connection you sent the ensureindex on, but ops from
256+ other connections can proceed in
257+ * that indexes are created on the foreground on secondaries in 2.0,
258+ which blocks replication & slave reads. In 2.2, it does not block reads (but
259+ still blocks repl).
260+
225261Drop Duplicates
226262```````````````
227263
228264To force the creation of a :ref:`unique index <index-type-unique>`
229- index, you can use the ``dropDups`` option. This will force MongoDB to
265+ index
266+
267+ TODO: " on a collection with duplicate values in the field to be indexed "
268+
269+ you can use the ``dropDups`` option. This will force MongoDB to
230270create a *unique* index by deleting documents with duplicate values
231271when building the index. Consider the following prototype invocation
232272of :func:`db.collection.ensureIndex()`:
@@ -243,12 +283,15 @@ See the full documentation of :ref:`duplicate dropping
243283 Specifying ``{ dropDups: true }`` will delete data from your
244284 database. Use with extreme caution.
245285
286+ TODO: I'd say it "may" delete data from your DB, not like it's going to go all
287+ Shermanesque on your data.
288+
246289.. _index-building-replica-sets:
247290
248291Building Indexes on Replica Sets
249292--------------------------------
250293
251- .. versionchanged:: 2.2
294+ .. versionchanged:: 2.2
252295 Index rebuilding operations on :term:`secondary` members of
253296 :term:`replica sets <replica set>` now run as normal background
254297 index operations. Run :func:`ensureIndex()
@@ -257,20 +300,30 @@ Building Indexes on Replica Sets
257300 the following operation to isolate and control the impact of
258301 indexing building operations on a set as a whole.
259302
303+ TODO: I think there needs to be a huge mention that this still blocks
304+ replication, so the procedure below is recommended.
305+
260306.. admonition:: For Version 1.8 and 2.0
261307
262308 :ref:`Background index creation operations
263309 <index-creation-background>` became *foreground* indexing
264310 operations on :term:`secondary` members of replica sets. These
265311 foreground operations will block all replication on the
266- secondaries, and can impact performance of the entire set. To build
312+ secondaries,
313+
314+ TODO: and don't allow any reads to go through.
315+
316+ and can impact performance of the entire set. To build
267317 indexes with minimal impact on a replica set, use the following
268318 procedure for all non-trivial index builds:
269319
270320 #. Stop the :program:`mongod` process on one secondary. Restart the
271- :program:`mongod` process *without* the :option:`--replSet <mongod --replSet>`
321+ :program:`mongod` process *without* the :option:`--replSet <mongod --replSet>`
272322 option. This instance is now in "standalone" mode.
273323
324+ TODO: generally we recommend running it on a different port, too, so that apps
325+ & other servers in the set don't try to contact it.
326+
274327 #. Create the new index or rebuild the index on this :program:`mongod`
275328 instance.
276329
@@ -287,7 +340,7 @@ Building Indexes on Replica Sets
287340
288341 Ensure that your :ref:`oplog` is large enough to permit the
289342 indexing or re-indexing operation to complete without falling
290- too far behind to catch up. See the ":ref:`replica-set-oplog-sizing`"
343+ too far behind to catch up. See the ":ref:`replica-set-oplog-sizing`"
291344 documentation for additional information.
292345
293346 .. note::
@@ -301,6 +354,9 @@ Building Indexes on Replica Sets
301354For the best results, always create indexes *before* you begin
302355inserting data into a collection.
303356
357+ TODO: well, sort of. That'll build the indexes fast, but make the inserts
358+ slower. Overall, it's faster to insert data, then build indexes.
359+
304360Measuring Index Use
305361-------------------
306362
@@ -318,7 +374,12 @@ following tools:
318374- :func:`cursor.hint()`
319375
320376 Append the :func:`hint() <cursor.hint()>` to any cursor (e.g.
321- query) with the name of an index as the argument to *force* MongoDB
377+ query) with the name
378+
379+ TODO: this isn't "the name of an index." I'd say just "with the index." The
380+ name of an index is a string like "zipcode_1".
381+
382+ of an index as the argument to *force* MongoDB
322383 to use a specific index to fulfill the query. Consider the following
323384 example:
324385
@@ -331,8 +392,13 @@ following tools:
331392 <cursor.explain()>` in conjunction with each other to compare the
332393 effectiveness of a specific index.
333394
395+ TODO: mention $natural to force no index usage?
396+
334397- :status:`indexCounters`
335398
336399 Use the :status:`indexCounters` data in the output of
337400 :dbcommand:`serverStatus` for insight into database-wise index
338401 utilization.
402+
403+ TODO: I'd like to see this also cover how to track how far an index build has
404+ gotten and how to kill an index build.
0 commit comments