Hint: Explain shows query stats, not data changes [OK]
Common Mistakes:
Thinking explain modifies data
Assuming explain creates indexes
Confusing query filter with data update
4. You wrote this MongoDB query to find users older than 25:
db.users.find({age: {$gt: 25}})
But it runs very slowly. What is the most likely reason?
medium
A. The age field is not indexed.
B. The query syntax is incorrect.
C. MongoDB does not support the $gt operator.
D. The collection name is wrong.
Solution
Step 1: Check query syntax correctness
The syntax is correct; $gt is a valid operator and collection name seems fine.
Step 2: Identify performance cause
Without an index on age, MongoDB must scan all documents, causing slow queries.
Final Answer:
The age field is not indexed. -> Option A
Quick Check:
Missing index = slow query [OK]
Hint: Slow queries often mean missing indexes [OK]
Common Mistakes:
Blaming syntax when it's correct
Thinking $gt is unsupported
Assuming wrong collection name without checking
5. You have a large MongoDB collection with millions of documents. You want to improve query speed for searches on email and status. Which approach best improves performance?
hard
A. Remove all indexes to speed up writes.
B. Create separate indexes on email and status fields.
C. Store email and status in a single string field.
D. Create a compound index on {email: 1, status: 1}.
Solution
Step 1: Understand compound vs separate indexes
A compound index on both fields allows efficient queries filtering on both email and status together.
Step 2: Evaluate options for best performance
Separate indexes help single-field queries but compound index is better for combined filters. Storing combined fields as string or removing indexes harms performance.
Final Answer:
Create a compound index on {email: 1, status: 1}. -> Option D
Quick Check:
Compound index = best multi-field query speed [OK]
Hint: Use compound indexes for multi-field queries [OK]
Common Mistakes:
Using separate indexes for combined queries
Combining fields into one string reduces query flexibility
Removing indexes slows queries
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.