why the “size” field of a collection stat is larger than “storageSize” or totalSize of a collection in mongodb. “count” : 1552400 "count" : 1552400, "size" : 1571028800.0, "avgObjSize" : 1012, "storageSize" : 229552128,

from my understanding of the above stats, "avgObjSize" gives the size of a document in the collection and "size" gives the sum size of all the documents(no index size included) in the collection. but when i computed the total size of a collection 264282112 bytes. this is less than "size" 1571028800 in bytes. storage engine i am using here is wiredTiger and block compresses "snappy " is enabled.

can anyone please explain when the document stored to disk, does it store as compressed or does it store with the size of "avgObjSize" (in my case 1012 bytes).
As per Mongodb documentation:


  The total size in memory of all records in a collection. This value
  does not include the record header, which is 16 bytes per record, but
  does include the record’s padding. Additionally size does not include
  the size of any indexes associated with the collection, which the
  totalIndexSize field reports.


You have :


The number of objects or documents in this collection = 1552400
The average size of an object in the collection (plus any
padding)=1012


1552400*1012=1589657600

Output shows 1571028800 which is very close to what is expected. 

How do you get 264282112?

Documents are compressed when stored in disk but storageSize shows allocated space.


  The total amount of storage allocated to this collection for document
  storage. The scale argument affects this value.
  
  storageSize does not include index size.