Docs Menu

Docs HomeDevelop ApplicationsMongoDB Manual

Find a Shard Key

Every shared collection has a shard key. To display the shard key, connect to a mongos instance and run the db.printShardingStatus() method:


The output resembles:

shard key: { <shard key> : <1 or hashed> }
unique: <boolean>
balancing: <boolean>
<shard name1> <number of chunks>
<shard name2> <number of chunks>
{ <shard key>: <min range1> } -->> { <shard key> : <max range1> } on : <shard name> <last modified timestamp>
{ <shard key>: <min range2> } -->> { <shard key> : <max range2> } on : <shard name> <last modified timestamp>
tag: <tag1> { <shard key> : <min range1> } -->> { <shard key> : <max range1> }

For more details on the db.printShardingStatus() output, see the sharded collection section on the sh.status() page.

← Set Missing Shard Key Fields