So I have a typical find().sort()
query that I run on my mongo collection.
db.collection.find({field1:1}).sort({field2:1})
Now, say I have three indexes on this collection:
- single index on
field1
- single index on
field2
- compound index on
field1
andfield2
-{field1:1,field2:1}
Now my question, how does mongoDB treat the above query? What are the indexes that will be used in a query like that- two single indexes or the one compound index?
If I remove the compound index, does it in fact make use of the two single indexes but slowing down?