OPTIONS

collStats

Definition

collStats

The collStats command returns a variety of storage statistics for a given collection. Use the following syntax:

{ collStats: "collection" , scale : 1024, verbose: true }

Specify the collection you want statistics for, and use the scale argument to scale the output: a value of 1024 renders the results in kilobytes.

Note

The scale factor rounds values to whole numbers.

Behavior

Verbosity and MMAPv1

The verbose: true option increases reporting for the MMAPv1 storage engine.

Unexpected Shutdown and Count

For MongoDB instances using the WiredTiger storage engine, after an unclean shutdown, statistics on size and count may off by up to 1000 documents as reported by collStats, dbStats, count. Run validate on the collection to restore the correct statistics for the collection.

Example Output

The following document provides a representation of the collStats output. Depending on the configuration of your collection and the storage engine, the output fields may include a subset of the fields.

{
  "ns" : <string>,
  "count" : <number>,
  "size" : <number>,
  "avgObjSize" : <number>,
  "storageSize" : <number>,
  "capped" : <boolean>,
  "max" : <number>,
  "maxSize" :  <number>,
  "wiredTiger" : {
     "metadata" : {
        "formatVersion" : <num>
     },
     "creationString" : <string>
     "type" :  <string>,
     "uri" :  <string>,
     "LSM" : {
        "bloom filters in the LSM tree" : <number>,
        "bloom filter false positives" : <number>,
        "bloom filter hits" : <number>,
        "bloom filter misses" : <number>,
        "bloom filter pages evicted from cache" : <number>,
        "bloom filter pages read into cache" : <number>,
        "total size of bloom filters" : <number>,
        "sleep for LSM checkpoint throttle" : <number>,
        "chunks in the LSM tree" : <number>,
        "highest merge generation in the LSM tree" : <number>,
        "queries that could have benefited from a Bloom filter that did not exist" : <number>,
        "sleep for LSM merge throttle" : <number>
     },
     "block-manager" : {
        "file allocation unit size" : <number>,
        "blocks allocated" : <number>,
        "checkpoint size" : <number>,
        "allocations requiring file extension" : <number>,
        "blocks freed" : <number>,
        "file magic number" : <number>,
        "file major version number" : <number>,
        "minor version number" : <number>,
        "file bytes available for reuse" : <number>,
        "file size in bytes" : <number>
     },
     "btree" : {
        "btree checkpoint generation" : <number>,
        "column-store variable-size deleted values" : <number>,
        "column-store fixed-size leaf pages" : <number>,
        "column-store internal pages" : <number>,
        "column-store variable-size leaf pages" : <number>,
        "pages rewritten by compaction" : <number>,
        "number of key/value pairs" : <number>,
        "fixed-record size" : <number>,
        "maximum tree depth" : <number>,
        "maximum internal page key size" : <number>,
        "maximum internal page size" :<number>,
        "maximum leaf page key size" : <number>,
        "maximum leaf page size" : <number>,
        "maximum leaf page value size" : <number>,
        "overflow pages" : <number>,
        "row-store internal pages" : <number>,
        "row-store leaf pages" : <number>
     },
     "cache" : {
        "bytes read into cache" : <number>,
        "bytes written from cache" : <number>,
        "checkpoint blocked page eviction" : <number>,
        "unmodified pages evicted" : <number>,
        "page split during eviction deepened the tree" : <number>,
        "modified pages evicted" : <number>,
        "data source pages selected for eviction unable to be evicted" : <number>,
        "hazard pointer blocked page eviction" : <number>,
        "internal pages evicted" : <number>,
        "pages split during eviction" : <number>,
        "in-memory page splits" : <number>,
        "overflow values cached in memory" : <number>,
        "pages read into cache" : <number>,
        "overflow pages read into cache" : <number>,
        "pages written from cache" : 2
     },
     "compression" : {
        "raw compression call failed, no additional data available" : <number>,
        "raw compression call failed, additional data available" : <number>,
        "raw compression call succeeded" : <number>,
        "compressed pages read" : <number>,
        "compressed pages written" : <number>,
        "page written failed to compress" : <number>,
        "page written was too small to compress" : 1
     },
     "cursor" : {
        "create calls" : <number>,
        "insert calls" : <number>,
        "bulk-loaded cursor-insert calls" : <number>,
        "cursor-insert key and value bytes inserted" : <number>,
        "next calls" : <number>,
        "prev calls" : <number>,
        "remove calls" : <number>,
        "cursor-remove key bytes removed" : <number>,
        "reset calls" : <number>,
        "search calls" : <number>,
        "search near calls" : <number>,
        "update calls" : <number>,
        "cursor-update value bytes updated" : <number>
     },
     "reconciliation" : {
        "dictionary matches" : <number>,
        "internal page multi-block writes" : <number>,
        "leaf page multi-block writes" : <number>,
        "maximum blocks required for a page" : <number>,
        "internal-page overflow keys" : <number>,
        "leaf-page overflow keys" : <number>,
        "overflow values written" : <number>,
        "pages deleted" : <number>,
        "page checksum matches" : <number>,
        "page reconciliation calls" : <number>,
        "page reconciliation calls for eviction" : <number>,
        "leaf page key bytes discarded using prefix compression" : <number>,
        "internal page key bytes discarded using suffix compression" : <number>
     },
     "session" : {
        "object compaction" : <number>,
        "open cursor count" : <number>
     },
     "transaction" : {
        "update conflicts" : <number>
     }
  },
  "nindexes" : <number>,         // number of indexes
  "totalIndexSize" : <number>,   // total index size in bytes
  "indexSizes" : {                // size of specific indexes in bytes
          "_id_" : <number>,
          "username" : <number>
  },
  // ...
  "ok" : <number>
}

Output

collStats.ns

The namespace of the current collection, which follows the format [database].[collection].

collStats.count

The number of objects or documents in this collection.

collStats.size

The total size in memory of all records in a collection. This value does not include the record header, which is 16 bytes per record, but does include the record’s padding. Additionally size does not include the size of any indexes associated with the collection, which the totalIndexSize field reports.

The scale argument affects this value.

collStats.avgObjSize

The average size of an object in the collection. The scale argument does not affect this value.

collStats.storageSize

The total amount of storage allocated to this collection for document storage. The scale argument affects this value.

storageSize does not include index size. See totalIndexSize for index sizing.

For MMAPv1, storageSize will not decrease as you remove or shrink documents.

collStats.numExtents

The total number of contiguously allocated data file regions. Only present when using the MMAPv1 storage engine.

collStats.nindexes

The number of indexes on the collection. All collections have at least one index on the _id field.

Changed in version 2.2: Before 2.2, capped collections did not necessarily have an index on the _id field, and some capped collections created with pre-2.2 versions of mongod may not have an _id index.

collStats.lastExtentSize

The size of the last extent allocated. The scale argument affects this value. Only present when using the mmapv1 storage engine.

collStats.paddingFactor

Deprecated since version 3.0.0: paddingFactor is no longer used in 3.0.0, and remains hard coded to 1.0 for compatibility only.

paddingFactor only appears when using the mmapv1 storage engine.

collStats.userFlags

New in version 2.2.

A number that indicates the user-set flags on the collection. userFlags only appears when using the mmapv1 storage engine.

Changed in version 3.0.0: userFlags reports on the usePowerOf2Sizes and the noPadding flags.

Note

MongoDB 3.0 ignores the usePowerOf2Sizes flag. See collMod and db.createCollection() for more information.

collStats.totalIndexSize

The total size of all indexes. The scale argument affects this value.

collStats.indexSizes

This field specifies the key and size of every existing index on the collection. The scale argument affects this value.

collStats.capped

This field will be “true” if the collection is capped.

collStats.max

Shows the maximum number of documents that may be present in a capped collection.

collStats.maxSize

Shows the maximum size of a capped collection.

collStats.wiredTiger

New in version 3.0.0.

wiredTiger only appears when using the WiredTiger storage engine.

This document contains data reported directly by the WiredTiger engine and other data for internal diagnostic use.

collStats.indexDetails

New in version 3.0.0.

A document that reports data from the WiredTiger storage engine for each index in the collection. Other storage engines will return an empty document.

The fields in this document are the names of the indexes, while the values themselves are documents that contain statistics for the index provided by the storage engine. These statistics are for internal diagnostic use.

←   buildInfo connPoolStats  →

Was this page helpful?

Yes No

Thank you for your feedback!

We're sorry! You can Report a Problem to help us improve this page.