MongoDB MCQ Questions - Optimization Strategies
This section focuses on "Optimization Strategies" in MongoDB. These Multiple Choice Questions (MCQ) should be practiced to improve the MongoDB skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. Which command returns a document that provides an overview of the database process's state?
A. serverStatus
B. currentQueue
C. currentQu
D. clientStatus
View Answer
Ans : A
Explanation: The serverStatus command returns a document that provides an overview of the database process's state
2. Which of the following setting defines what constitutes a "slow" operation?
A. fastOpThresholdMs
B. slowOpThresholdZs
C. slowOpThresholdMs
D. slowOpThresholdGs
View Answer
Ans : C
Explanation: The operationProfiling.slowOpThresholdMs setting is available only for mongod.
3. _________provide the number of times the lock acquisitions encountered deadlocks.
A. locks.deadlock
B. lock.deadlockCount
C. lock.deadlock
D. locks.deadlockCount
View Answer
Ans : D
Explanation: The globalLock data structure contains information regarding the database’s current lock state, historical lock status, current operation queue, and the number of active clients.
4. _________ returns the queryPlanner information for the evaluated method.
A. db.explain()
B. db.collection.explain()
C. collection.explain()
D. explain()
View Answer
Ans : B
Explanation: db.collection.explain() returns the queryPlanner information for the evaluated method.
5. Point out the correct statement.
A. For read-heavy applications, deploy sharding and add one or more shards to a sharded cluster to distribute load among mongod instances
B. Spikes in the number of available connections can also be the result of application or driver errors
C. For read-heavy applications, increase the size of your replica set and distribute read operations to secondary members
D. All of the above
View Answer
Ans : C
Explanation: Extremely high numbers of connections, particularly without corresponding workload is often indicative of a driver or other configuration error.
6. With which storage engine, MongoDB uses memory-mapped files to store data?
A. MMAPv2
B. MMAPv1
C. WiredTiger
D. All of the above
View Answer
Ans : B
Explanation: Given a data set of sufficient size, the mongod process will allocate all available memory on the system for its use.
7. _________ returns the queryPlanner and executionStats information for the evaluated method.
A. cursor.explain()
B. tablescan.explain()
C. server.explain()
D. client.explain()
View Answer
Ans : A
Explanation: cursor.explain() returns the queryPlanner and executionStats information for the evaluated method.
8. If MongoDB can use an index scan to obtain the requested sort order, the result will not include a SORT stage
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : B
Explanation: If MongoDB uses indexes for a $or expression, the result will include the OR stage with an inputStages array that details the indexes
9. Which of the following provides information on the MongoDB instance?
A. serverInfo
B. queryPlanner
C. executeStats
D. None of the above
View Answer
Ans : A
Explanation: The verbosity mode (i.e. queryPlanner, executionStats, allPlansExecution) determines whether the results include executionStats and whether executionStats includes data captured during plan selection.
10. If the query planner selects a _________ the explain result includes an IXSCAN stage.
A. Document
B. Replica Set
C. Index
D. None of the above
View Answer
Ans : C
Explanation: MongoDB runs the query optimizer to choose the winning plan for the operation under evaluation
Discussion