MongoDB Questions and Answers Part-13

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

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

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

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

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

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

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

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

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

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

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

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

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

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