Answer the question
In order to leave comments, you need to log in
What is the correct way to use indexes in MongoDB?
Recently, I became interested in MongoDB and sat down to read what it is for the weekend, and faced the fact that I don’t quite understand how indexes are arranged in Mongo
. The query is parsed:
db.users.find({"age" : {"$gte" : 25, "$lte" : 35}}).
sort({"username" : 1}).limit(100)
and it is advised to take the following index {"username" : 1, "age" : 1}, instead of Answer the question
In order to leave comments, you need to log in
db.users.find({"age" : {"$gte" : 25, "$lte" : 35}}).sort({"username" : 1}).limit(100)
it is advised to take the following index {" username" : 1, "age" : 1}, instead of
{"age":1,"username":1}.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question