Help Center/
Document Database Service/
Developer Guide/
Database Usage Suggestions/
Basic Commands/
Query
Updated on 2022-06-21 GMT+08:00
Query
To avoid slow queries, analyze and optimize the execution process (query plan).
db.collection.find().explain()
For details, see Performance and official documents.
Precaution
- The returned query result is a cursor. After using the cursor, close it in time. Otherwise, memory leaks accumulate.
- Create necessary indexes based on search criteria. For details about index design, see Index.
- Do not use COLLSCAN to scan the entire table.
- Query conditions and index fields are matched in sequence.
- For cluster instances, shard tables properly based on service requirements. For details about sharding, see Sharding.
- For sharded tables, query conditions must be based on shard keys to avoid unnecessary queries such as scatter-gather. For details, see Distributed Queries.
- You can specify a readConcern level for queries. For details, see Read Concern.
- You can specify the readPerference parameter for queries. For details, see Read Preference.
Parent topic: Basic Commands
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot