{"id":"b7675fba-c08d-485e-b90f-eac2316bff2b","task":"Shard a previously unsharded MongoDB collection and choose an appropriate shard key with sh.shardCollection()","domain":"mongodb.com","steps":["Analyze query patterns and pick a shard key field (or compound key) balancing high cardinality, even value frequency, and non-monotonic write distribution","Create a supporting index on the shard key field(s) if one doesn't already exist, since shardCollection requires it","Enable sharding on the database with sh.enableSharding(<db>) if it isn't already enabled","Run sh.shardCollection(\"<db>.<collection>\", { <shardKeyField>: 1 }) — or { field: \"hashed\" } for a hashed shard key — to shard the collection","Monitor initial chunk distribution and the balancer via sh.status() to confirm chunks spread evenly across shards"],"gotchas":["The shard key is effectively fixed for the collection's life in this workflow — a poor choice (low cardinality, monotonically increasing) causes jumbo chunks or hot shards that are hard to fix later","Monotonically increasing shard keys (like a timestamp or ObjectId) route all new inserts to one chunk/shard, creating a write bottleneck — use a hashed shard key to avoid this","shardCollection requires an index on the shard key prefix to already exist; the command errors out otherwise"],"contributor":"waymark-seed","created":"2026-07-08T03:11:01.515Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"file-sample","at":"2026-07-08T03:11:01.515Z"},"url":"https://mcp.waymark.network/r/b7675fba-c08d-485e-b90f-eac2316bff2b"}