Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (50.2k points)

I know that the below command will return the statistics regarding the collection:

db.collection.stats()

But in my output, my actual disk size is getting matched with the storage size. Refer to the below output:

    "count" : 20696445,

    "size" : NumberLong("1478263842661"),

    "storageSize" : 334732324864,

    "totalIndexSize" : 676327424,

    "indexSizes" : {

            "_id_" : 377094144,

            "leadID_1" : 128049152,

            "leadID_hashed" : 171184128

    },

    "avgObjSize" : 71425.97884134208

Can someone guide me what is the size for the other fields that are present inside the collection?

1 Answer

0 votes
by (107k points)
edited by

The output of the collection.stats() function will mainly depend on the version of the MongoDB server. In your code, you have not mentioned your MongoDB server version. I think you are working with WiredTiger Storage Engine as this storage engine will by default compress all your data and indexes that are present inside your collection. 

In the output, you are having 1.4TB of data(uncompressed) which is utilizing 334GB of the disk. In your indexSizes, the storage size that is being used by indexes is described separately.

To help you gain a better understanding, here is a Full Stack Developer Certification Course provided by Intellipaat.

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
2 answers
0 votes
2 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...