Docs HomeMongoDB Manual

Time Series Compression时间序列压缩

This page describes how MongoDB compresses data in time series collections, and how you can optimize compression.本页介绍MongoDB如何压缩时间序列集合中的数据,以及如何优化压缩。

Default Compression Algorithm默认压缩算法

Time series collections use zstd compression, which differs from the global default compression algorithm, snappy.时间序列集合使用zstd压缩,这与全局默认压缩算法snappy不同。

Column Compression柱压缩

Starting in MongoDB 5.2, time series collections use column compression. 从MongoDB 5.2开始,时间序列集合使用列压缩Column compression adds a number of innovations that work together to significantly improve practical compression, reduce your data's overall storage on disk, and improve read performance.列压缩增加了许多创新,这些创新共同作用,显著提高了实际压缩效果,减少了数据在磁盘上的总体存储,并提高了读取性能。

These enhancements further reduce size of data on disk when compressed with zstd, and also significantly reduce space used in the WiredTiger cache.当使用zstd压缩时,这些增强功能进一步减小了磁盘上的数据大小,还显著减少了WiredTiger缓存中使用的空间。

The types of compression introduced are:引入的压缩类型有:

  • Delta Encoding增量编码
  • Object compression对象压缩
  • Array compression (starting in MongoDB 6.0)数组压缩(从MongoDB 6.0开始)
  • Run Length encoding (RLE)游程长度编码(RLE)

Delta Encoding (Delta Compression)增量编码(增量压缩)

Delta Encoding takes advantage of the data in your time series collection having time-series characteristics. Instead of storing absolute values, Delta Encoding assumes that the measurements will not change rapidly between each other. 增量编码利用时间序列集合中具有时间序列特征的数据。德尔塔编码不是存储绝对值,而是假设测量值不会在彼此之间快速变化。This approach reduces the amount of information required by only storing the difference between measurements.这种方法通过仅存储测量之间的差异来减少所需的信息量。

Delta of Delta Encoding (Delta of Delta Compression)增量编码(增量压缩)

With data that increases monotonically, Delta of Delta Encoding can further minimize the size of the number stored by calculating a delta of the delta itself.对于单调增加的数据,增量编码可以通过计算增量本身的增量来进一步最小化存储的数字的大小。

Object and Array Compression对象和数组压缩

Column compression ensures that if you are using objects and arrays in your documents, you receive the same compression benefits had those embedded fields existed at the root level of your document.列压缩可以确保,如果您在文档中使用对象和数组,则可以获得与那些嵌入字段存在于文档根级别时相同的压缩优势。

Learn More了解更多信息

To learn how to optimize compression, see Optimize Compression.要了解如何优化压缩,请参阅优化压缩