MongoDB Questions and Answers – Sharded Cluster Behavior

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Sharded Cluster Behavior”.

1. When a chunk grows beyond the chunk size, MongoDB attempts to split the chunk into smaller chunks, always based on ranges in the _____________
a) replica set
b) shard key
c) tag sets
d) all of the mentioned
View Answer

Answer: c
Explanation: Administrators create and associate tags with ranges of the shard key, and then assign those tags to the shards.

2. Point out the correct statement.
a) The shard key determines the distribution of the collection’s documents among the cluster’s shards
b) The shard key is either an indexed field or an indexed compound field that exists in every document in the collection
c) Each range, or chunk, defines a non-overlapping range of shard key values
d) All of the mentioned
View Answer

Answer: d
Explanation: MongoDB distributes the chunks, and their documents, among the shards in the cluster.

3. The index on the shard key cannot be a _________ index.
a) single
b) multkikey
c) unique
d) all of the mentioned
View Answer

Answer: b
Explanation: Shard keys are immutable and cannot be changed after insertion.

4. Hashed shard keys use a ________ index of a single field as the shard key to partition data across your sharded cluster.
a) hashed
b) unique
c) multkikey
d) all of the mentioned
View Answer

Answer: a
Explanation: The field you choose as your hashed shard key should have a good cardinality, or large number of different values.

advertisement
advertisement

5. Point out the correct statement.
a) Hashed keys do not work well with fields that increase monotonically like ObjectId values or timestamps
b) If you shard an empty collection using a hashed shard key, MongoDB will automatically create and migrate chunks so that each shard has two chunks
c) Hashed keys work well with ObjectId values only
d) All of the mentioned
View Answer

Answer: b
Explanation: Hashed keys work well with fields that increase monotonically like ObjectId values or timestamps.

6. You can control how many chunks MongoDB will create with the ___________ parameter.
a) numChunks
b) numInitialChunks
c) numberofchunks
d) all of the mentioned
View Answer

Answer: b
Explanation: Applications do not need to compute hashes.

Note: Join free Sanfoundry classes at Telegram or Youtube

7. MongoDB automatically computes the hashes when resolving queries using ______ indexes.
a) hashed
b) unique
c) muiltkey
d) all of the mentioned
View Answer

Answer: c
Explanation: During a chunk migration, the destination shard is sent all the current documents in the chunk from the origin shard.

8. MongoDB generates _______ values upon document creation to produce a unique identifier for the object.
a) ObjectId
b) CompId
c) DoctId
d) All of the mentioned
View Answer

Answer: a
Explanation: Some possible shard keys will allow your application to take advantage of the increased write capacity that the cluster can provide, while others do not.

advertisement

9. A shard key that increases monotonically will not hinder performance if most of your write operations are ____ operations.
a) insert()
b) update()
c) delete()
d) all of the mentioned
View Answer

Answer: b
Explanation: Generally, choose shard keys that have both high cardinality and will distribute write operations across the entire cluster.

10. The mongos provides an interface for applications to interact with sharded clusters that hides the complexity of data ______
a) partitioning
b) replication
c) sharding
d) none of the mentioned
View Answer

Answer: a
Explanation: A mongos receives queries from applications, and uses metadata from the config server, to route queries to the mongod instances with the appropriate data.

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.