MongoDB Questions and Answers – Optimization Strategies – 3

«
»

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

Answer: c
Explanation: executionStats contains statistics that describe the completed query execution for the winning plan.

advertisement

2. Which of the following provides information on the MongoDB instance?
a) serverInfo
b) queryPlanner
c) executeStats
d) none of the mentioned
View Answer

Answer: 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.

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

Answer: b
Explanation: explain.executionStats.executionTimeMillis is total time in milliseconds required for query plan selection and query execution.

advertisement
advertisement

4. For sharded collections, explain returns the __________ for each accessed shard.
a) clientInfo
b) serverInfo
c) serverplan
d) all of the mentioned
View Answer

Answer: b
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

Answer: a
Explanation: If MongoDB uses indexes for a $or expression, the result will include the OR stage with an inputStages array that details the indexes

advertisement

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

Answer: a
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

Answer: b
Explanation: The mode affects the behavior of explain() and determines the amount of information to return.

advertisement

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

Answer: b
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

Answer: a
Explanation: MongoDB runs the query optimizer to choose the winning plan for the operation under evaluation.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Reference Books in MongoDB.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter