OPTIONS

db.collection.indexStats()

Definition

db.collection.indexStats(index)

Aggregates statistics for the B-tree data structure that stores data for a MongoDB index. The indexStats() method is a thin wrapper around the indexStats command. The indexStats() method is available only on mongod instances running with the --enableExperimentalIndexStatsCmd option.

Important

The indexStats() method is not intended for production deployments.

The indexStats() method has the following form:

db.<collection>.indexStats( { index: "<index name>" } )

The indexStats() method has the following parameter:

Parameter Type Description
index document The index name.

The method takes a read lock and pages into memory all the extents, or B-tree buckets, encountered. The method might be slow for large indexes if the underlying extents are not already in physical memory. Do not run indexStats() on a replica set primary. When run on a secondary, the command causes the secondary to fall behind on replication.

The method aggregates statistics for the entire B-tree and for each individual level of the B-tree. For a description of the command’s output, see indexStats.

For more information about running indexStats(), see https://github.com/mongodb-labs/storage-viz#readme.