Running the collStats command – db.collection.stats() – returns all sizes in bytes, e.g.
> db.foo.stats()
{
"size" : 715578011834, // total size (bytes)
"avgObjSize" : 2862, // average size (bytes)
}
However, if you want the results in another unit then you can also pass in a scale
argument.
For example, to get the results in KB:
> db.foo.stats(1024)
{
"size" : 698806652, // total size (KB)
"avgObjSize" : 2, // average size (KB)
}
Or for MB:
> db.foo.stats(1024 * 1024)
{
"size" : 682428, // total size (MB)
"avgObjSize" : 0, // average size (MB)
}