blob: 9d56737cb601d42230cba636c2b02f21b70d5c2a [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[41],{438:function(e,s,t){"use strict";t.r(s);var n=t(29),a=Object(n.a)({},(function(){var e=this,s=e._self._c;return s("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[s("h1",{attrs:{id:"compression"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#compression"}},[e._v("#")]),e._v(" Compression")]),e._v(" "),s("p",[e._v("When the time series is written and encoded as binary data according to the specified type, IoTDB compresses the data using compression technology to further improve space storage efficiency. Although both encoding and compression are designed to improve storage efficiency, encoding techniques are usually available only for specific data types (e.g., second-order differential encoding is only suitable for INT32 or INT64 data type, and storing floating-point numbers requires multiplying them by 10m to convert to integers), after which the data is converted to a binary stream. The compression method (SNAPPY) compresses the binary stream, so the use of the compression method is no longer limited by the data type.")]),e._v(" "),s("h2",{attrs:{id:"basic-compression-methods"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#basic-compression-methods"}},[e._v("#")]),e._v(" Basic Compression Methods")]),e._v(" "),s("p",[e._v("IoTDB allows you to specify the compression method of the column when creating a time series, and supports the following compression methods:")]),e._v(" "),s("ul",[s("li",[s("p",[e._v("UNCOMPRESSED")])]),e._v(" "),s("li",[s("p",[e._v("SNAPPY")])]),e._v(" "),s("li",[s("p",[e._v("LZ4")])]),e._v(" "),s("li",[s("p",[e._v("GZIP")])])]),e._v(" "),s("p",[e._v("The specified syntax for compression is detailed in "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Reference/SQL-Reference.html"}},[e._v("Create Timeseries Statement")]),e._v(".")],1),e._v(" "),s("h2",{attrs:{id:"sdt"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#sdt"}},[e._v("#")]),e._v(" SDT")]),e._v(" "),s("p",[e._v("The Swinging Door Trending (SDT) algorithm is a lossy compression algorithm.\nSDT has low computational complexity and uses a linear trend to represent a quantity of data.")]),e._v(" "),s("p",[e._v("In IoTDB SDT compresses and discards data when flushing into the disk.")]),e._v(" "),s("p",[e._v("IoTDB allows you to specify the properties of SDT when creating a time series, and supports three properties:")]),e._v(" "),s("ul",[s("li",[e._v("CompDev (Compression Deviation)")])]),e._v(" "),s("p",[e._v("CompDev is the most important parameter in SDT that represents the maximum difference between the\ncurrent sample and the current linear trend. CompDev needs to be greater than 0 to perform compression.")]),e._v(" "),s("ul",[s("li",[e._v("CompMinTime (Compression Minimum Time Interval)")])]),e._v(" "),s("p",[e._v("CompMinTime is a parameter measures the time distance between two stored data points, which is used for noisy reduction.\nIf the time interval between the current point and the last stored point is less than or equal to its value,\ncurrent point will NOT be stored regardless of compression deviation.\nThe default value is 0 with time unit ms.")]),e._v(" "),s("ul",[s("li",[e._v("CompMaxTime (Compression Maximum Time Interval)")])]),e._v(" "),s("p",[e._v("CompMaxTime is a parameter measure the time distance between two stored data points.\nIf the time interval between the current point and the last stored point is greater than or equal to its value,\ncurrent point will be stored regardless of compression deviation.\nThe default value is 9,223,372,036,854,775,807 with time unit ms.")]),e._v(" "),s("p",[e._v("The specified syntax for SDT is detailed in "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Reference/SQL-Reference.html"}},[e._v("Create Timeseries Statement")]),e._v(".")],1),e._v(" "),s("p",[e._v("Supported datatypes:")]),e._v(" "),s("ul",[s("li",[e._v("INT32 (Integer)")]),e._v(" "),s("li",[e._v("INT64 (Long Integer)")]),e._v(" "),s("li",[e._v("FLOAT (Single Precision Floating Point)")]),e._v(" "),s("li",[e._v("DOUBLE (Double Precision Floating Point)")])]),e._v(" "),s("p",[e._v("The following is an example of using SDT compression.")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> CREATE TIMESERIES root.sg1.d0.s0 WITH DATATYPE=INT32,ENCODING=PLAIN,LOSS=SDT,COMPDEV=2\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Prior to flushing and SDT compression, the results are shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> SELECT s0 FROM root.sg1.d0\n+-----------------------------+--------------+\n| Time|root.sg1.d0.s0|\n+-----------------------------+--------------+\n|2017-11-01T00:06:00.001+08:00| 1|\n|2017-11-01T00:06:00.002+08:00| 1|\n|2017-11-01T00:06:00.003+08:00| 1|\n|2017-11-01T00:06:00.004+08:00| 1|\n|2017-11-01T00:06:00.005+08:00| 1|\n|2017-11-01T00:06:00.006+08:00| 1|\n|2017-11-01T00:06:00.007+08:00| 1|\n|2017-11-01T00:06:00.015+08:00| 10|\n|2017-11-01T00:06:00.016+08:00| 20|\n|2017-11-01T00:06:00.017+08:00| 1|\n|2017-11-01T00:06:00.018+08:00| 30|\n+-----------------------------+--------------+\nTotal line number = 11\nIt costs 0.008s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br"),s("span",{staticClass:"line-number"},[e._v("17")]),s("br"),s("span",{staticClass:"line-number"},[e._v("18")]),s("br")])]),s("p",[e._v("After flushing and SDT compression, the results are shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> FLUSH\nIoTDB> SELECT s0 FROM root.sg1.d0\n+-----------------------------+--------------+\n| Time|root.sg1.d0.s0|\n+-----------------------------+--------------+\n|2017-11-01T00:06:00.001+08:00| 1|\n|2017-11-01T00:06:00.007+08:00| 1|\n|2017-11-01T00:06:00.015+08:00| 10|\n|2017-11-01T00:06:00.016+08:00| 20|\n|2017-11-01T00:06:00.017+08:00| 1|\n+-----------------------------+--------------+\nTotal line number = 5\nIt costs 0.044s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("p",[e._v("SDT takes effect when flushing to the disk. The SDT algorithm always stores the first point and does not store the last point.")]),e._v(" "),s("p",[e._v("The data in [2017-11-01T00:06:00.001, 2017-11-01T00:06:00.007] is within the compression deviation thus discarded.\nThe data point at time 2017-11-01T00:06:00.007 is stored because the next data point at time 2017-11-01T00:06:00.015\nexceeds compression deviation. When a data point exceeds the compression deviation, SDT stores the last read\npoint and updates the upper and lower boundaries. The last point at time 2017-11-01T00:06:00.018 is not stored.")]),e._v(" "),s("h2",{attrs:{id:"compression-ratio-statistics"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#compression-ratio-statistics"}},[e._v("#")]),e._v(" Compression Ratio Statistics")]),e._v(" "),s("p",[e._v("Compression ratio statistics file: data/system/storage_groups/compression_ratio/Ratio-{ratio_sum}-{memtable_flush_time}")]),e._v(" "),s("ul",[s("li",[e._v("ratio_sum: sum of memtable compression ratios")]),e._v(" "),s("li",[e._v("memtable_flush_time: memtable flush times")])]),e._v(" "),s("p",[e._v("The average compression ratio can be calculated by "),s("code",[e._v("ratio_sum / memtable_flush_time")])])])}),[],!1,null,null,null);s.default=a.exports}}]);