collStats Command

Statistics on a collection. The command name is "collStats" and the shell helper is database.collection.stats().

> db.commandHelp("collStats")
help for: collStats { collStats:"blog.posts" , scale : 1 } scale divides sizes e.g. for KB use 1024

In the shell:

> // to see params etc.:
> db.foo.stats
function (scale) {
    return this._db.runCommand({collstats:this._shortName, scale:scale});
}

// to run:
> db.foo.stats()
{
        "ns" : "test.foo",
        "count" : 9,           // number of documents
        "size" : 432,          // collection size
        "avgObjSize" : 48,     // average object size in bytes
        "storageSize" : 3840,  // (pre)allocated space for the collection
        "numExtents" : 1,      // extents are contiguously allocated 
                               // chunks of datafile space
        "nindexes" : 2,
        "lastExtentSize" : 3840,
        "paddingFactor" : 1,   // padding can make updates faster 
                               // if documents grow
        "flags" : 1,
        "totalIndexSize" : 16384,
        "indexSizes" : {
                "_id_" : 8192,
                "x_1" : 8192
        },
        "ok" : 1
}
  • Slave ok : true
  • Lock type : read
  • Slow to run : no

Follow @mongodb

MongoDB Pittsburgh - May 15
MongoNYC - May 23
MongoDB Paris - Jun 14
MongoDB UK - Jun 20
MongoDC - June 26


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus