I know I can use db.collection.totalIndexSize()
to get the total index size, but I'm interested in seeing the size of an individual index.
Is this supported?
Learn commands in MongoDB get data size of database and storage size of database using db. stats(). MongoDB get index size and index storage size of a database using db.
The length of the index name cannot be longer than 125 characters. A compound index can have maximum 31 fields indexed.
MongoDB provides complete support for indexes on any field in a collection of documents. By default, all collections have an index on the _id field, and applications and users may add additional indexes to support important queries and operations. This document describes ascending/descending indexes on a single field.
collection. totalSize() method is used to reports the total size of a collection, including the size of all documents and all indexes on a collection. Returns: The total size in bytes of the data in the collection plus the size of every index on the collection.
Certainly can. db.collection.stats().indexSizes
is an embedded document where each index name is a key and the value is the total index size in bytes :
> db.test.stats() { "ns" : "test.test", <snip> "indexSizes" : { "_id_" : 137904592, "a_1" : 106925728 }, "ok" : 1 }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With