skip to content
Alvin Lucillo

Collection stats

/ 1 min read

To retrieve a collection’s usage and storage details, you can use stats(). For example, in the output below, it shows the total number of documents and total size of the collection.

db.users.stats()
{
  ...
  sharded: false,
  size: 38,
  count: 1,
  numOrphanDocs: 0,
  storageSize: 20480,
  totalIndexSize: 20480,
  totalSize: 40960,
  indexSizes: { _id_: 20480 },
  avgObjSize: 38,
  ns: 'test.users',
  nindexes: 1,
  scaleFactor: 1
}