Databases Reference
In-Depth Information
Databases
The
databases
collection contains a list of databases that exist on the shards and infor-
mation about them:
> db.databases.find()
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "foo", "partitioned" : false, "primary" : "shard1" }
{ "_id" : "x", "partitioned" : false, "primary" : "shard0" }
{
"_id" : "test",
"partitioned" : true,
"primary" : "shard0",
"sharded" : {
"test.foo" : {
"key" : {"x" : 1},
"unique" : false
}
}
}
Every database available is listed here and has some basic information available.
"_id" : string
The
_id
is the database's name.
"partitioned" : boolean
If
"partitioned"
is true, then the
enablesharding
command has been run on this
database.
"primary" : string
The value corresponds to a shard
"_id"
and indicates where this database's “home”
is. A database always has a home, whether it is sharded. In a sharded setup, a new
database will be created on a random shard. This home is where it will start creating
data files. If it is sharded, it will use other servers as well, but it will start out on
this shard.
Chunks
Chunk information is stored in the
chunks
collection. This is where things get more
interesting; you can actually see how your data has been divided up across the cluster:
> db.chunks.find()
{
"_id" : "test.foo-x_MinKey",
"lastmod" : { "t" : 1276636243000, "i" : 1 },
"ns" : "test.foo",
"min" : {
"x" : { $minKey : 1 }
},
"max" : {
"x" : { $maxKey : 1 }
},