MongoDB Questions and Answers – Analyze Query Performance

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Analyze Query Performance”.

1. Indexes are typically available in ______ or located sequentially on disk.
a) RAM
b) ROM
c) CMOS
d) None of the mentioned
View Answer

Answer: a
Explanation: Querying only the index can be much faster than querying documents outside of the index.

2. Point out the wrong statement.
a) Query selectivity refers to how well the query predicate excludes or filters out documents in a collection
b) Query selectivity can determine whether or not queries can use indexes effectively or even use indexes at all
c) More selective queries match a larger percentage of documents
d) All of the mentioned
View Answer

Answer: c
Explanation: More selective queries match a smaller percentage of documents.

3. ___________ is used to determine whether a query is a covered query.
a) explainstats()
b) explain()
c) explainall()
d) all of the mentioned
View Answer

Answer: b
Explanation: db.collection.explain() provides information on the execution of other operations, such as db.collection.update().

4. The ________ message is used to update a document in a collection.
a) UPDATE
b) OP_UPDATE
c) OP_UPDATES
d) All of the mentioned
View Answer

Answer: b
Explanation: Only the OP_QUERY and OP_GET_MORE messages result in a response from the database.

advertisement
advertisement

5. Point out the correct statement.
a) An equality match on the unique _id field is less selective as it can match at most one document
b) The selectivity of regular expressions depends on the expressions themselves
c) Less selective queries can use indexes effectively or even at all
d) All of the mentioned
View Answer

Answer: b
Explanation: If an index exists for the field, then MongoDB matches the regular expression against the values in the index, which can be faster than a collection scan.

6. _____ can modify specific fields of an existing document or documents or replace an existing document entirely, depending on the update parameter.
a) modify()
b) update()
c) find()
d) none of the mentioned
View Answer

Answer: b
Explanation: By default, the update() method updates a single document.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

7. The update() method uses the _______ command, which uses the default write concern.
a) find
b) read
c) update
d) modify
View Answer

Answer: c
Explanation: The update() method returns an object that contains the status of the operation.

8. _________ is used to view statistics about the query plan for a given query.
a) db.explain()
b) cursor.explain()
c) cursor.explainstats()
d) all of the mentioned
View Answer

Answer: b
Explanation: This information can help as you develop indexing strategies.

advertisement

9. A ________ query plan has returned a threshold number of matching results.
a) execution
b) unordered
c) ordered
d) none of the mentioned
View Answer

Answer: c
Explanation: An ordered query plan has returned all the matching results.

10. A query _______ consists of a combination of query, sort, and projection specifications.
a) plan
b) shape
c) stats
d) all of the mentioned
View Answer

Answer: b
Explanation: Index filters determine which indexes the optimizer evaluates for a query shape.

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.