We are using Mongo 2.6 in our application. We upgraded from 2.4 to 2.6 version.
Will the order be maintained in case of mongo 2.6 query based on different individual indexes.
Thanks.
We are using Mongo 2.6 in our application. We upgraded from 2.4 to 2.6 version.
Will the order be maintained in case of mongo 2.6 query based on different individual indexes.
Thanks.
As long as you explicitly use sort()
in your queries, the order will remain the same in version 2.4.
If your queries don't specify sorting order using sort()
, there is a change in Mongo DB 2.6 that may affect the result order of your queries. MongoDB can now use the intersection of multiple indexes to fulfill queries. If you have two individual indexes:
db.collection.ensureIndex({A: 1})
db.collection.ensureIndex({B: 1})
and you don't have the compound index:
db.collection.ensureIndex({A: 1, B: 1})
The query db.collection.find({A : a, B: b})
will return the results sorted by both A and B in version 2.6. In version 2.4, it is sorted by A only. For more details, check out this http://docs.mongodb.org/manual/core/index-intersection/