This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Optimization Strategies – 3”.
1. ____________ does not provide query execution information for the rejected plans.
a) serverstats
b) queryPlanner
c) executionStats
d) all of the mentioned
View Answer
Explanation: executionStats contains statistics that describe the completed query execution for the winning plan.
2. Which of the following provides information on the MongoDB instance?
a) serverInfo
b) queryPlanner
c) executeStats
d) none of the mentioned
View Answer
Explanation: The verbosity mode (i.e. queryPlanner, executionStats, allPlansExecution) determines whether the results include executionStats and whether executionStats includes data captured during plan selection.
3. _________ corresponds to the millis field returned by cursor.explain() in earlier versions of MongoDB.
a) executionMillis
b) executionTimeMillis
c) timemillis
d) all of the mentioned
View Answer
Explanation: explain.executionStats.executionTimeMillis is total time in milliseconds required for query plan selection and query execution.
4. For sharded collections, explain returns the __________ for each accessed shard.
a) clientInfo
b) serverInfo
c) serverplan
d) all of the mentioned
View Answer
Explanation: For sharded collections, explain returns the core query planner and server information for each accessed shard in the shards field
5. Point out the wrong statement.
a) If MongoDB can use an index scan to obtain the requested sort order, the result will not include a SORT stage
b) In previous versions of MongoDB, cursor.explain() returned the scanAndOrder field to specify whether MongoDB could use the index order to return sorted results
c) If MongoDB uses indexes for a $and expression, the result will include the AND stage with an inputStages array that details the replicata sets
d) None of the mentioned
View Answer
Explanation: If MongoDB uses indexes for a $or expression, the result will include the OR stage with an inputStages array that details the indexes
6. If the query planner selects a collection scan, the explain result includes a _________ stage.
a) COLLSCAN
b) TABLESCAN
c) ROWSCAN
d) All of the mentioned
View Answer
Explanation: The format and fields of the explain results have changed from previous versions.
7. Which of the following parameter specifies the verbosity mode for the explain output?
a) verbosity
b) verbose
c) queryPlanner
d) none of the mentioned
View Answer
Explanation: The mode affects the behavior of explain() and determines the amount of information to return.
8. In _____________ mode, MongoDB returns statistics describing the execution of the winning plan as well as statistics for the other candidate plans captured during plan selection.
a) somePlansExecution
b) allPlansExecution
c) rejPlansExecution
d) none of the mentioned
View Answer
Explanation: cursor.explain() returns the queryPlanner and executionStats information for the evaluated method.
9. If the query planner selects a _________ the explain result includes an IXSCAN stage.
a) Index
b) Replica Set
c) Document
d) None of the mentioned
View Answer
Explanation: MongoDB runs the query optimizer to choose the winning plan for the operation under evaluation.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check MongoDB Books
- Check Information Technology Books
- Practice Programming MCQs
- Apply for Programming Internship