Skip to content

Commit 48261b5

Browse files
author
Bob Grabar
committed
DOCS-654 new 2.0 index format
1 parent 53933b1 commit 48261b5

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

source/release-notes/2.0.txt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Read through all release notes before upgrading, and ensure that no
2424
changes will affect your deployment.
2525

2626
If you create new indexes in 2.0, then downgrading to 1.8 is possible
27-
but you must reindex the new collections. For more information on 2.0
28-
indexes and on rollback, see :wiki:`Index Versions`.
27+
but you must reindex the new collections.
2928

3029
:program:`mongoimport` and :program:`mongoexport` now correctly adhere to the CSV spec
3130
for handling CSV input/output. This may break existing import/export
@@ -43,6 +42,26 @@ In addition, you may see reduced write throughput.
4342
:program:`mongod` instances; however, for best results, upgrade your
4443
deployments using the following procedures:
4544

45+
.. _2.0-convert-to-new-index-format:
46+
47+
Converting an Existing Index to the New Format
48+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49+
50+
To convert all indexes for a given collection to the
51+
:ref:`2.0 type <2.0-new-index-format>`, invoke the
52+
:doc:`compact </reference/command/compact>` command.
53+
54+
All operations that create a new index will result in a 2.0 index by
55+
default. For example:
56+
57+
- Reindexing results on an older-version index results in a 2.0 index.
58+
However, reindexing on a secondary does *not* work in versions prior
59+
to 2.0. Do not reindex on a secondary. For a workaround, see
60+
:issue:`SERVER-3866`.
61+
62+
- The :setting:`repair` database command converts indexes to a 2.0
63+
indexes.
64+
4665
.. _2.0-upgrade-standalone:
4766

4867
Upgrading a Standalone ``mongod``
@@ -130,6 +149,8 @@ swapped out if unused, some operating systems do this slowly enough that
130149
it might be an issue. The default stack size is lesser of the
131150
system setting or 1MB.
132151

152+
.. _2.0-new-index-format:
153+
133154
Index Performance Enhancements
134155
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135156

@@ -145,6 +166,8 @@ from 819 to 1024 bytes.
145166
Once you create new indexes, downgrading to 1.8.x will require a
146167
re-index of any indexes created using 2.0.
147168

169+
.. seealso:: :ref:`2.0-convert-to-new-index-format`
170+
148171
Sharding Authentication
149172
~~~~~~~~~~~~~~~~~~~~~~~
150173

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
================================
2+
Roll Back to a Version 1.8 Index
3+
================================
4+
5+
.. default-domain:: mongodb
6+
7+
8+
MongoDB version 2.0 and later supports the old index format. But old versions
9+
will not support the new format. If you need to roll back to an older
10+
version, the server will run, but queries and other operations involving
11+
the newer indexes will log and return an error. Thus, you will need to
12+
re-create any new index you would like to use on an old server.
13+
14+
Versions prior to 1.8.2, inclusive, are not aware of the index version
15+
field. If you rollback a ``{v:1}`` index to 1.8.2 and re-index it, its
16+
version will still be marked ``{v: 1}``, although it actual is now version ``{v:0}``.
17+
If you upgrade again to 2.0, this index will not work, even though it is
18+
marked as ``{v: 1}`` in ``system.indexes``. If you must roll back to a
19+
version prior to 1.8.2, you must delete the index then create it again
20+
(instead of simply re-indexing).
21+
22+
Building a {v:0} Index
23+
----------------------
24+
25+
You can still create a ``{v:0}`` index with MongoDB version 2.0 or later. To do so, add the
26+
option ``{v:0}`` in the index creation command. For example in the :program:`mongo`
27+
shell:
28+
29+
.. code-block:: javascript
30+
31+
// defaults to a v:1 index
32+
db.foo.ensureIndex({name:1})
33+
db.system.indexes.find()
34+
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "mydb.foo", "name" : "_id_" }
35+
{ "v" : 1, "key" : { "name" : 1 }, "ns" : "mydb.foo", "name" : "name_1" }
36+
db.foo.dropIndex({name:1})
37+
{ "nIndexesWas" : 2, "ok" : 1 }
38+
39+
// create a v:0 index
40+
db.foo.ensureIndex({name:1},{v:0})
41+
db.system.indexes.find()
42+
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "mydb.foo", "name" : "_id_" }
43+
44+
{ "v" : 0, "key" : { "name" : 1 }, "ns" : "mydb.foo", "name" : "name_1" }
45+
46+
.. seealso:: :ref:`2.0-new-index-format` and :ref:`2.0-convert-to-new-index-format`

0 commit comments

Comments
 (0)