A
A
Anton2021-02-11 12:03:22
MongoDB
Anton, 2021-02-11 12:03:22

How to execute query faster in MongoDb?

Hello.
There are 27 million documents in the db.users collection and I'm interested in selecting one array field (1 nesting level).
Can you please tell me how to determine the query execution time: db.users.find({"cred.0.shortnumber" : "123"})?
Which index will help you complete the query as quickly as possible? Now launched db.userscreateIndex({"cred.0.shortnumber" : 1}), and something hangs for an hour, and it is not known whether it will be faster than the very first request? =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2021-02-11
@hunk3r

The index really helped: the hourly query was completed in 1 second.
Thanks everyone for the replies.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question