Before performing operations that may cause risks, such as modifying instance configurations or data:
Check the disaster recovery and fault tolerance capabilities of the instance to ensure data security.
Create snapshots or enable log backup before modifying Elastic Compute Service (ECS) or Relational Database Service (RDS) instances.
Modify sensitive information, such as logon account credentials, promptly after sharing them in the Alibaba Cloud Management Console.
ApsaraDB for MongoDB records slow query details in the system.profile collection of each database. Profiling is enabled by default, so you can query system.profile immediately without any additional setup.
Query slow query records
Connect to your instance using the mongo shell, switch to the target database, and run queries against system.profile.
Return the 10 most recent slow queries:
db.system.profile.find().limit(10).sort({ ts: -1 }).pretty()Return operations that took longer than 100 milliseconds:
db.system.profile.find({ millis: { $gt: 100 } }).pretty()Return slow queries sorted by execution time (slowest first):
db.system.profile.find().sort({ millis: -1 }).limit(20).pretty()Each document in system.profile includes the operation type (op), namespace (ns), execution time in milliseconds (millis), and the timestamp (ts).
What's next
For guidance on analyzing slow queries and optimizing query performance, see Analyze slow queries in ApsaraDB for MongoDB.