0
0
MongoDBquery~10 mins

Identifying missing indexes in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to list all indexes on the 'users' collection.

MongoDB
db.users.[1]()
Drag options to blanks, or click blank then click option'
AlistIndexes
BfindIndexes
CshowIndexes
DgetIndexes
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'findIndexes' which does not exist.
Using 'showIndexes' which is not a valid method.
Using 'getIndexes' which is incorrect.
2fill in blank
medium

Complete the code to check the current index usage statistics for the 'orders' collection.

MongoDB
db.orders.[1]()
Drag options to blanks, or click blank then click option'
AgetIndexStats
BindexStats
CshowIndexStats
DlistIndexStats
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getIndexStats' which is not a MongoDB method.
Using 'showIndexStats' which does not exist.
Using 'listIndexStats' which is invalid.
3fill in blank
hard

Complete the code to find slow queries that might need indexes in the 'products' collection.

MongoDB
db.[1]({ millis: { $gt: 100 } })
Drag options to blanks, or click blank then click option'
AgetProfilingStatus
Bsystem.profile.find()
Cprofile.find
Dsystem.profile.find
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getProfilingStatus' which only returns profiling settings.
Using 'system.profile.find()' which is a method call, not a property.
Using 'profile.find' which is not a valid collection name.
4fill in blank
hard

Fill both blanks to create an index on the 'email' field in the 'customers' collection to improve query speed.

MongoDB
db.customers.createIndex({ [1]: [2] })
Drag options to blanks, or click blank then click option'
Aemail
B1
C-1
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'username' instead of 'email' as the field name.
Using -1 when ascending order is intended.
Swapping the field name and index order.
5fill in blank
hard

Fill all three blanks to create a compound index on 'lastName' (ascending) and 'age' (descending) fields in the 'employees' collection.

MongoDB
db.employees.createIndex({ [1]: [2], [3]: -1 })
Drag options to blanks, or click blank then click option'
AlastName
B1
Cage
DfirstName
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'firstName' instead of 'lastName'.
Using -1 for the first field instead of 1.
Swapping the field names.