Recall & Review
beginner
What is the purpose of the MongoDB profiler?
The MongoDB profiler helps find slow queries and operations by recording detailed information about database activities, so you can improve performance.
Click to reveal answer
beginner
How do you enable the MongoDB profiler to log slow queries only?
Use
db.setProfilingLevel(1, { slowms: 100 }) to log queries slower than 100 milliseconds.Click to reveal answer
beginner
Where does MongoDB store the profiler data?
Profiler data is stored in the
system.profile collection inside the current database.Click to reveal answer
beginner
What command shows the current profiling level in MongoDB?
Run
db.getProfilingStatus() to see the current profiler level and slowms threshold.Click to reveal answer
intermediate
How can you find the slowest queries recorded by the profiler?
Query
db.system.profile.find().sort({ millis: -1 }).limit(5) to get the top 5 slowest queries.Click to reveal answer
What profiling level logs all database operations in MongoDB?
✗ Incorrect
Level 2 logs all operations, including slow and fast queries.
Which collection holds the profiler data in MongoDB?
✗ Incorrect
Profiler data is stored in the system.profile collection.
How do you set the profiler to log only queries slower than 200ms?
✗ Incorrect
Level 1 with slowms option logs only slow queries above 200ms.
Which command shows the current profiler status?
✗ Incorrect
db.getProfilingStatus() returns the current profiling level and slowms.
What does the
millis field in profiler data represent?✗ Incorrect
The millis field shows how long the query took to run in milliseconds.
Explain how to enable and use the MongoDB profiler to find slow queries.
Think about setting the profiler level and where to find the data.
You got /4 concepts.
Describe the difference between profiling levels 0, 1, and 2 in MongoDB.
Consider what each level records.
You got /3 concepts.