Database Reference
In-Depth Information
"collections" : 4,
"objects" : 200012,
"dataSize" : 7200832,
"storageSize" : 21258496,
"numExtents" : 11,
"indexes" : 3,
"indexSize" : 27992064,
"ok" : 1
}
You can also run the stats() command on an individual collection:
> db.numbers.stats()
{
"ns" : "tutorial.numbers",
"count" : 200000,
"size" : 7200000,
"storageSize" : 21250304,
"numExtents" : 8,
"nindexes" : 2,
"lastExtentSize" : 10066176,
"paddingFactor" : 1,
"flags" : 1,
"totalIndexSize" : 27983872,
"indexSizes" : {
"_id_" : 21307392,
"num_1" : 6676480
},
"ok" : 1
}
Some of the values provided in these result documents are useful only in complicated
debugging situations. But at the very least, you'll be able to find out how much space a
given collection and its indexes are occupying.
2.3.2
How commands work
A certain set of MongoDB operations—distinct from the insert, update, delete, and
query operations described so far in this chapter—are known as database commands .
Database commands are generally administrative, as with the stats() methods just
presented, but they may also control core MongoDB features, such as map-reduce.
Regardless of the functionality they provide, what all database commands have in
common is their implementation as queries on a special virtual collection called $cmd .
To s h o w w h at t h i s m e a n s , l e t 's t a k e a q u i ck e x a m p l e . R e c a l l h o w y o u i n v o k e d t h e
stats() database command:
> db.stats()
The stats() method is a helper that wraps the shell's command invocation method.
Tr y e n t e r i n g t h e f o l l o w in g e q u i v a l e n t o p e r a t io n :
> db.runCommand( {dbstats: 1} )
Search WWH ::




Custom Search