db.collection.totalSize()
mongo
Shell Method
This page documents the mongo
shell method, and doesnot refer to the MongoDB Node.js driver (or any other driver)method. For corresponding MongoDB driver API, refer to your specificMongoDB driver documentation instead.
Returns:The total size in bytes of the data in the collection plusthe size of every index on the collection.If collection data is compressed (which is thedefault for WiredTiger
), the returnedsize reflects the compressed size of the collection data.
If an index uses prefix compression (which is thedefault for WiredTiger
), the returned sizereflects the compressed size of the index.
The value returned is the sum ofdb.collection.storageSize()
anddb.collection.totalIndexSize()
in bytes.