Challenge - 5 Problems
Profiler Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Find slow queries using MongoDB profiler
You have enabled the MongoDB profiler to log slow queries taking longer than 100 milliseconds. Which query will return all slow queries recorded in the profiler?
MongoDB
db.system.profile.find({ millis: { $gt: 100 } })Attempts:
2 left
💡 Hint
The profiler stores the execution time of queries in the 'millis' field.
✗ Incorrect
The MongoDB profiler records the execution time of operations in the 'millis' field. To find slow queries, you filter documents where 'millis' is greater than the threshold.
🧠 Conceptual
intermediate1:30remaining
Profiler levels in MongoDB
Which profiler level setting in MongoDB logs only slow operations exceeding the configured threshold?
Attempts:
2 left
💡 Hint
Profiler levels control how much detail is recorded.
✗ Incorrect
Level 1 enables profiling only for operations slower than the slowms threshold. Level 2 logs all operations. Level 0 disables profiling.
📝 Syntax
advanced2:00remaining
Enable profiler for slow queries over 200ms
Which command correctly enables the MongoDB profiler to log queries slower than 200 milliseconds?
MongoDB
db.setProfilingLevel(1, { slowms: 200 })
Attempts:
2 left
💡 Hint
The first argument is the profiling level, the second is an options object.
✗ Incorrect
The correct syntax is db.setProfilingLevel(level, options). Level 1 enables slow operation profiling with the slowms threshold set in options.
🔧 Debug
advanced2:00remaining
Why does this profiler query return no results?
You run this query to find slow queries: db.system.profile.find({ millis: { $gt: 50 } }).sort({ ts: -1 }).limit(5). But it returns no documents, even though you know slow queries occurred. What is the most likely reason?
Attempts:
2 left
💡 Hint
Profiler must be enabled to collect data.
✗ Incorrect
If the profiler is disabled (level 0), no profiling data is collected, so the query returns no results.
❓ optimization
expert2:30remaining
Optimize slow query detection with profiler
You want to detect slow queries but minimize performance impact. Which profiler setting balances detailed slow query logging with minimal overhead?
Attempts:
2 left
💡 Hint
Higher slowms reduces profiling frequency and overhead.
✗ Incorrect
Level 1 with a high slowms threshold logs only very slow queries, reducing overhead compared to logging all operations or very low thresholds.