stats() - Prints collection statistics

Prints statistics for the collection. Unavailable values are set to -1.

Syntax diagram

Read syntax diagramSkip visual syntax diagramdb.collection. stats(scale)

Command arguments

scale
This optional argument specifies the scale of the size field in the collection statistics. The following values are supported:
  • 0 = bytes (default)
  • 1 = KB
  • 2 = MB
  • 3 = GB
Any other numerical values are ignored.

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
  }