|
MongoDB v2.0 uses a new data structure for its indexes. The new {v:1} indexes are, on average, 25% smaller than the old {v:0} indexes. This usually results in significantly increased performance. In addition, signed (pre 1970) dates are supported in {v:1} indexes. Backward-compatibility with {v:0} indexes is maintained. Thus, you can upgrade to MongoDB v2.0 seamlessly. However, to get the benefits of the new index format, you'll need to reindex. Converting an Existing Index to {v:1} formatAll operations that create a new index will result in a {v:1} index by default.
In v2.0.1, the following operations will convert {v:0} indexes to {v:1} type:
Rolling Back to MongoDB < v2.0While MongoDB v2.0 supports the old index format, old versions will not support the new format. If you need to roll back to an old version, the server will run, but queries and other operations involving the newer indexes will log and return an error. Thus, you'll need to recreate any new index you'd like to use on an old server. Versions >= 1.8.3 are aware of the index version field, but version <= 1.8.2 are not. So if you rollback a [v:1} index to 1.8.2 and re-index it its version will still be marked {v: 1} although it actual version is {v: 0}. Then if you upgrade again to 2.0 this index won't work even though they are marked as {v: 1} in db.system.indexes. So if you have to rollback to a version <= 1.8.2, you must delete the index then create it again (instead of simply re-indexing). Building a {v:0} IndexYou can still create a {v:0} index with MongoDB v2.0. To do so, add the option {v:0} in the index creation command. For example in the mongo shell: > // defaults to a v:1 index > db.foo.ensureIndex({name:1}) > db.system.indexes.find() { "v" : 1, "key" : { "_id" : 1 }, "ns" : "mydb.foo", "name" : "_id_" } { "v" : 1, "key" : { "name" : 1 }, "ns" : "mydb.foo", "name" : "name_1" } > db.foo.dropIndex({name:1}) { "nIndexesWas" : 2, "ok" : 1 } > // create a v:0 index > db.foo.ensureIndex({name:1},{v:0}) > db.system.indexes.find() { "v" : 1, "key" : { "_id" : 1 }, "ns" : "mydb.foo", "name" : "_id_" } { "v" : 0, "key" : { "name" : 1 }, "ns" : "mydb.foo", "name" : "name_1" } |

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus