0
0
MongoDBquery~20 mins

Profiler for slow queries in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Profiler Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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 } })
Adb.system.profile.find({ millis: { $gt: 100 } })
Bdb.system.profile.find({ duration: { $gt: 100 } })
Cdb.system.profile.find({ time: { $gte: 100 } })
Ddb.system.profile.find({ executionTimeMillis: { $gt: 100 } })
Attempts:
2 left
💡 Hint
The profiler stores the execution time of queries in the 'millis' field.
🧠 Conceptual
intermediate
1:30remaining
Profiler levels in MongoDB
Which profiler level setting in MongoDB logs only slow operations exceeding the configured threshold?
ALevel 0 - No profiling
BLevel 3 - Logs errors only
CLevel 1 - Logs slow operations only
DLevel 2 - Logs all operations
Attempts:
2 left
💡 Hint
Profiler levels control how much detail is recorded.
📝 Syntax
advanced
2: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 })
Adb.setProfilingLevel({ level: 1, slowms: 200 })
Bdb.setProfilingLevel(2, { slowms: 200 })
Cdb.setProfilingLevel(1, 200)
Ddb.setProfilingLevel(1, { slowms: 200 })
Attempts:
2 left
💡 Hint
The first argument is the profiling level, the second is an options object.
🔧 Debug
advanced
2: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?
AThe query syntax is invalid and causes an error
BProfiler is not enabled or set to level 0
CThe 'millis' field does not exist in profiler documents
DThe sort order should be ascending (1) instead of descending (-1)
Attempts:
2 left
💡 Hint
Profiler must be enabled to collect data.
optimization
expert
2: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?
ASet profiler level to 1 with a high slowms threshold (e.g., 500ms)
BSet profiler level to 2 to log all operations
CSet profiler level to 0 and rely on logs only
DSet profiler level to 1 with slowms set to 1ms
Attempts:
2 left
💡 Hint
Higher slowms reduces profiling frequency and overhead.