C100DBA · Question #73
Which of the following is true about sharding?
The correct answer is B. We cannot change a shard key directly/automatically once it is set up. Option B is correct because shard keys are effectively immutable once a collection is sharded - changing them requires a full data dump, dropping the collection, and re-importing, making it a manual and disruptive process rather than a direct/automatic operation. Option A is wron
Question
Which of the following is true about sharding?
Options
- ACreating a sharded key automatically creates an index on the collection using that key
- BWe cannot change a shard key directly/automatically once it is set up
- CA sharded environment does not support sorting functionality since the documents lie on various
- DSharding is enabled at the database level
How the community answered
(22 responses)- B91% (20)
- C5% (1)
- D5% (1)
Explanation
Option B is correct because shard keys are effectively immutable once a collection is sharded - changing them requires a full data dump, dropping the collection, and re-importing, making it a manual and disruptive process rather than a direct/automatic operation.
Option A is wrong because a shard key index is not automatically created in all cases; for existing collections, you must manually create the index on the shard key before sharding the collection, or the operation will fail.
Option C is wrong because sharded environments do support sorting - the mongos router performs a merge sort across the results returned from each shard before delivering the final sorted output to the client.
Option D is wrong because while you do call sh.enableSharding() at the database level as a prerequisite, sharding itself (the shard key, chunk distribution, and data partitioning) is configured and applied at the collection level, not the database level.
Memory tip: Think of a shard key like concrete - once it sets, you can't reshape it without tearing the whole thing apart. The "B = Baked in" trick helps you remember that shard keys are permanent once applied.
Topics
Community Discussion
No community discussion yet for this question.