stats() - Prints collection statistics
Prints statistics for the collection. Unavailable values are set to -1.
Syntax diagram
Command arguments
- scale
- This optional argument specifies the scale of the
sizefield in the collection statistics. The following values are supported:- 0 = bytes (default)
- 1 = KB
- 2 = MB
- 3 = GB
Example
Example 1: Collect statistics for
the books collection.
db.books.stats()Sample
output: {
"ns":"TEST.books",
"count":15,
"size":234567,
"avgObjSize":309.0,
"numExtents":-1,
"nindexes":2,
"totalIndexSizes":-1,
"indexSizes":[{"books_xauthor": -1},{"_id_":-1}],
"ok":1
}