What is the difference between a v:1 index and a v:2 index?

What are the differences between version 1 indexes and version 2 indexes?

e.g. here’s an example of what i mean by a v:2 index: { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "db1.metrics" }

I assume some performance improvements have been made but it would help if someone could share any documentation explaining what the specific differences are.

Hi @Edward_Murphy,

The v2 index format is a MongoDB 3.4+ index improvement that adds support for collation and the Decimal128 BSON type (both new features in 3.4).

If your deployment was previously upgraded from MongoDB 3.2 or earlier, you may still have some v1 indexes as these were not automatically upgraded (recreating indexes on large populated collections can have significant impact on a production environment). Any new indexes will be created as v2 (or latest index version for your server release).

Existing v1 indexes can be rebuilt as v2 (or latest index version) by either dropping and recreating a specific index, or using the reIndex command to recreate all indexes for a collection.



This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.