Courseiva
Sharding →easyMultiple Choice

C100DBA Sharding Practice Question

A DBA is preparing to shard a collection in a MongoDB 6.0 cluster. The collection currently has no indexes other than the default _id index. The chosen shard key is { userId: 1 }. What must the DBA do before running shardCollection?

⚠ Common exam trap

The trap here is overlooking the index prerequisite and assuming sharding can proceed on a collection with no supporting index for the shard key.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Create an index on userId, because a sharded collection requires a supporting index on the shard key.

Before sharding a collection, MongoDB requires an index whose leading fields match the shard key. Without it, the shardCollection command returns an error. Creating an index on userId satisfies this requirement and enables the cluster to manage chunk boundaries and route queries. Emptying the collection or disabling the balancer is unnecessary and would not satisfy the actual prerequisite.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Create an index on userId, because a sharded collection requires a supporting index on the shard key.

    Why this is correct

    MongoDB requires an index that starts with the shard key fields before a collection can be sharded. If no such index exists, shardCollection fails. Creating an index on userId satisfies this requirement. The index is used to enforce chunk boundaries and support routing, so it must exist prior to the sharding operation.

  • ✗

    Convert the shard key to a hashed key first, because ranged shard keys cannot be applied to existing collections.

    Why it's wrong here

    Ranged shard keys can absolutely be applied to existing collections. There is no requirement to convert to hashed sharding. The only index-related prerequisite is a supporting index on the chosen shard key fields. Hashed sharding is a design choice, not a mandatory precursor to sharding an existing collection.

  • ✗

    Set the collection to unsharded status and disable the balancer for the duration of the operation.

    Why it's wrong here

    The collection must not already be sharded, but disabling the balancer is not a prerequisite for shardCollection. In fact, the balancer may need to run afterward to distribute chunks. Setting an unsharded status is not a valid prerequisite step; the operation itself transitions the collection from unsharded to sharded.

  • ✗

    Move the collection to the primary shard and ensure it is empty, because only empty collections can be sharded.

    Why it's wrong here

    Collections do not need to be empty to be sharded. MongoDB can shard a populated collection, distributing existing data into chunks across shards. Requiring an empty collection would make sharding impractical for production workloads. The only hard prerequisite related to indexes is that a supporting index on the shard key must exist.

About these practice questions

One of 222 original C100DBA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DBA practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DBA exam.