Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between "size" and "storageSize" displayed by Mongo stats() function

What is difference between "size" and "storageSize" displayed by Mongo stats() function? Which one shows the actual size on disk for a particular collection? Refer sample data returned by command

db.getCollection('temp_collection').stats()


{"ns" : "DB1.temp_collection",
    "count" : 1035219,
    "size" : 1186,
    "avgObjSize" : 1202,
    "storageSize" : 177,
    "capped" : false,
    "wiredTiger" : 
}
like image 620
user6790571 Avatar asked Sep 06 '16 09:09

user6790571


1 Answers

in simple words:

  • size refers for logical allocation (this is seen by database engine)
  • storageSize refers for physical file space allocation

As WT (WiredTiger) is used, with enabled data compression, then physical allocation is smaller because of compression

db.collection.storageSize

db.collection.stats

like image 175
profesor79 Avatar answered Oct 20 '22 01:10

profesor79