Help Center/ Document Database Service/ Developer Guide/ Database Usage Suggestions/ Basic Commands/ Query
Updated on 2022-09-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
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.