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.

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

Note: Join free Sanfoundry classes at Telegram or Youtube

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 Books in MongoDB.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.