How can MongoDB dataSize be larger than storageSize?

前端 未结 2 1119
渐次进展
渐次进展 2021-01-02 01:08

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

相关标签:
2条回答
  • 2021-01-02 01:30

    The storageSize metric is equal to the size (in bytes) of all the data extents in the database. Without compression, this number is larger than dataSize because it includes yet-unused space (in data extents) and space vacated by deleted or moved documents within extents. However, as you are using the WiredTiger storage engine, data is compressed on the disk and is therefore smaller than the dataSize.

    0 讨论(0)
  • 2021-01-02 01:34

    MongoDB 3.0 with WiredTiger engine uses 'snappy' compression by default. If this affects your DB performance, you can consider to turn it off (blockCompressor: none) in the mongod.conf file:

    storage:
      engine: wiredTiger
      wiredTiger:
        collectionConfig:
          blockCompressor: none
    
    0 讨论(0)
提交回复
热议问题