250+ TOP MCQs on Indexes In MongoDB and Answers

MongoDB Multiple Choice Questions on “Indexes In MongoDB”.

1. MongoDB indexes use a _______ data structure.
a) Hash
b) Map
c) B-tree
d) All of the mentioned

Answer: b
Clarification: MongoDB provides a number of different index types to support specific types of data and queries.

2. Point out the correct statement.
a) If an appropriate index exists for a query, MongoDB cannot use the index to limit the number of documents it must inspect
b) Indexes support the efficient execution of queries in MongoDB
c) The index stores the location of a specific field or set of fields, ordered by the value of the field
d) None of the mentioned

Answer: b
Clarification: Without indexes, MongoDB must perform a collection scan.

3. MongoDB supports the creation of user-defined ascending/descending indexes on a ______ field of a document.
a) Single
b) Non Unique
c) Compound
d) None of the mentioned

Answer: a
Clarification: If applications do not specify a value for _id the driver or the mongod will create an _id field with an ObjectId value.

4. The ______ index is unique and prevents clients from inserting two documents with the same value for the _id field.
a) _id
b) $default
c) _def
d) None of the mentioned

Answer: a
Clarification: All MongoDB collections have an index on the _id field that exists by default.

5. Point out the wrong statement.
a) MongoDB can return sorted results by using the ordering in the index
b) MongoDB defines indexes at the collection level and supports indexes on any field or sub-field of the documents in a MongoDB collection
c) Fundamentally, indexes in MongoDB is different to indexes in other database systems
d) None of the mentioned

Answer: c
Clarification: Indexes are special data structures that store a small portion of the collection’s data set in an easy to traverse form.

6. MongoDB also supports user-defined indexes on multiple fields called ____________
a) compound
b) composite
c) candidate
d) none of the mentioned

Answer: a
Clarification: The order of fields listed in a compound index has significance.

7. MongoDB uses ______ indexes to index the content stored in arrays.
a) singlekey
b) multikey
c) compkey
d) none of the mentioned

Answer: b
Clarification: If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array.

8. ___________ indexes use spherical geometry to return results.
a) 3dsphere
b) 2dsphere
c) 1dsphere
d) none of the mentioned

Answer: b
Clarification: To support efficient queries of geospatial coordinate data, MongoDB provides two special indexes.

9. MongoDB provides a ________ index type that supports searching for string content in a collection.
a) string
b) text
c) char
d) none of the mentioned

Answer: b
Clarification: These text indexes do not store language-specific stop words (e.g. “the”, “a”, “or”) and stem the words in a collection to only store root words.

10. _____ indexes uses planar geometry when returning results.
a) 2d
b) 1d
c) 3d
d) All of the mentioned

Answer: a
Clarification: MongoDB computes geohash values for the coordinate pairs within the specified location range and then indexes the geohash values.

Leave a Reply

Your email address will not be published. Required fields are marked *