- Reference >
- mongo Shell Methods >
- Collection Methods >
- db.collection.getIndexStats()
db.collection.getIndexStats()¶
Definition¶
- db.collection.getIndexStats(index)¶
Displays a human-readable summary of aggregated statistics about an index’s B-tree data structure. The information summarizes the output returned by the indexStats command and indexStats() method. The getIndexStats() method displays the information on the screen and does not return an object.
The getIndexStats() method has the following form:
db.<collection>.getIndexStats( { index : "<index name>" } )
Parameter Type Description index document The index name. The getIndexStats() method is available only when connected to a mongod instance that uses the --enableExperimentalIndexStatsCmd option.
To view index names for a collection, use the getIndexes() method.
警告
Do not use getIndexStats() or indexStats with production deployments.
Example¶
The following command returns information for an index named type_1_traits_1:
db.animals.getIndexStats({index:"type_1_traits_1"})
The command returns the following summary. For more information on the B-tree statistics, see indexStats.
-- index "undefined" --
version 1 | key pattern { "type" : 1, "traits" : 1 } | storage namespace "test.animals.$type_1_traits_1"
2 deep, bucket body is 8154 bytes
bucket count 45513 on average 99.401 % (±0.463 %) full 49.581 % (±4.135 %) bson keys, 49.820 % (±4.275 %) key nodes
-- depth 0 --
bucket count 1 on average 71.511 % (±0.000 %) full 36.191 % (±0.000 %) bson keys, 35.320 % (±0.000 %) key nodes
-- depth 1 --
bucket count 180 on average 98.954 % (±5.874 %) full 49.732 % (±5.072 %) bson keys, 49.221 % (±5.161 %) key nodes
-- depth 2 --
bucket count 45332 on average 99.403 % (±0.245 %) full 49.580 % (±4.130 %) bson keys, 49.823 % (±4.270 %) key nodes