Adding Index to Composite Index on Mongodb
1 answer
A call ensureIndex
with different fields will create a new index.
You can confirm this after running both commands with getIndexes
to find out what indexes exist for your collection:
db.collection.getIndexes()
If you no longer need the original index, you can remove it using:
db.collection.dropIndex({a:1,b:1})
+5
source to share