How is MongoDB data size larger than storageSize?

As far as I understand, the storage size for MongoDB should always be larger than the data size. However, after upgrading to Mongo 3.0 and using WiredTiger, I begin to see that the data size is larger than the storage size.

Here from one of the databases:

{ "db" : "Results", "collections" : NumberInt(1), "objects" : NumberInt(251816), "avgObjSize" : 804.4109548241573, "dataSize" : NumberInt(202563549), "storageSize" : NumberInt(53755904), "numExtents" : NumberInt(0), "indexes" : NumberInt(5), "indexSize" : NumberInt(41013248), "ok" : NumberInt(1) } 

Note that 202563549> 53755904 is far ahead. I am confused how this can be. The way to read db.stats() now different from Mongo 3.0?

+5
source share
2 answers

The storageSize label is the size (in bytes) of all data extents in the database. Without compression, this number is larger than dataSize, because it includes unused space (in extents) and space freed by deleted or moved documents within extents. However, since you use the WiredTiger storage WiredTiger , data is compressed on disk and therefore smaller than dataSize.

+8
source

MongoDB 3.0 with the WiredTiger engine uses "instant" compression by default. If this affects the performance of your database, you can disable it (blockCompressor: none) in the mongod.conf file:

 storage: engine: wiredTiger wiredTiger: collectionConfig: blockCompressor: none 
+1
source

Source: https://habr.com/ru/post/1237291/


All Articles