This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Index Types – 1”.
1. To support ________ based sharding, MongoDB provides a hashed index type.
a) primary
b) root
c) hash
d) all of the mentioned
View Answer
Explanation: These indexes have a more random distribution of values along their range, but only support equality matches and cannot support range-based queries.
2. Point out the correct statement.
a) Whether the use of a compound index or the use of an index intersection is more efficient depends on the particular query and the system
b) Certain restrictions apply to indexes, such as the length of the index keys or the number of indexes per collection
c) For queries that specify compound query conditions, if one index can fulfill a part of a query condition, and another index can fulfill another part of the query condition, then MongoDB can use the intersection of the two indexes to fulfill the query
d) None of the mentioned
View Answer
Explanation: In general, each index intersection involves two indexes; however, MongoDB can employ multiple/nested index intersections to resolve a query.
3. ________ index type, which indexes the hash of the value of a field.
a) Hashed
b) Unique
c) Multikey
d) None of the mentioned
View Answer
Explanation: Hashed indexes support equality matches and cannot support range-based queries.
4. The _________ property for an index causes MongoDB to reject duplicate values for the indexed field.
a) Hashed
b) Unique
c) Multikey
d) None of the mentioned
View Answer
Explanation: Other than the unique constraint, unique indexes are functionally interchangeable with other MongoDB indexes.
5. Point out the wrong statement.
a) TTL index is ideal for certain types of information like machine generated event data, logs, and session information that only need to persist in a database for a finite amount of time
b) You cannot combine the sparse index option with the unique index option
c) TTL indexes are special indexes that MongoDB can use to automatically remove documents from a collection after a certain amount of time
d) None of the mentioned
View Answer
Explanation: You can combine to reject documents that have duplicate values for a field but ignore documents that do not have the indexed key.
6. The ______ property of an index ensures that the index only contain entries for documents that have the indexed field.
a) Hashed
b) Unique
c) Sparse
d) None of the mentioned
View Answer
Explanation: The index skips documents that do not have the indexed field.
7. MongoDB can use the _________ of indexes to fulfill queries.
a) union
b) intersection
c) projection
d) none of the mentioned
View Answer
Explanation: The $project takes a document that can specify the inclusion of fields, the suppression of the _id field, the addition of new fields, and the resetting the values of existing fields.
8. Which of the following method is to verify whether MongoDB used index intersection?
a) explain()
b) analyze()
c) intersect()
d) none of the mentioned
View Answer
Explanation: To determine if MongoDB used index intersection, run explain(); the results of explain() will include either an AND_SORTED stage or an AND_HASH stage.
9. An index prefix is a subset of a ______ index, consisting of one or more keys starting from the beginning of the index.
a) Hashed
b) Unique
c) Sparse
d) Compound
View Answer
Explanation: With index intersection, MongoDB can use an intersection of either the entire index or the index prefix.
10. Index __________ does not eliminate the need for creating compound indexes.
a) union
b) addition
c) intersection
d) all of the mentioned
View Answer
Explanation: Compound index may not support a query condition that does not include the index prefix keys or that specifies a different sort order.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check Information Technology Books
- Check MongoDB Books
- Practice Programming MCQs
- Apply for Programming Internship