blob: 050f7895905fb7e2b14a2f07d71cf0bfeb6faacb [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[65],{632:function(e,t,a){"use strict";a.r(t);var s=a(70),r=Object(s.a)({},(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[a("h1",{attrs:{id:"continuous-query-cq"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#continuous-query-cq"}},[e._v("#")]),e._v(" Continuous Query, CQ")]),e._v(" "),a("p",[e._v("We can create, drop a CQ,\nand query all registered CQ configuration information through SQL statements.")]),e._v(" "),a("h2",{attrs:{id:"sql-statements"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#sql-statements"}},[e._v("#")]),e._v(" SQL statements")]),e._v(" "),a("h3",{attrs:{id:"create-cq"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#create-cq"}},[e._v("#")]),e._v(" Create CQ")]),e._v(" "),a("h4",{attrs:{id:"syntax"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#syntax"}},[e._v("#")]),e._v(" Syntax")]),e._v(" "),a("div",{staticClass:"language-sql line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-sql"}},[a("code",[a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("CREATE")]),e._v(" CONTINUOUS QUERY "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("cq_id"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v(" \n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("RESAMPLE EVERY "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("every_interval"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("FOR")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("for_interval"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("BEGIN")]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("SELECT")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("function")]),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("path_suffix"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("INTO")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("full_path"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("|")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("node_name"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("FROM")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("path_prefix"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("GROUP")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("BY")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("time")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),e._v("group_by_interval"),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("level")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),e._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v("<")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("level")]),a("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("END")]),e._v("\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br")])]),a("ul",[a("li",[a("code",[e._v("<cq_id>")]),e._v(" specifies the globally unique id of CQ.")]),e._v(" "),a("li",[a("code",[e._v("<every_interval>")]),e._v(" specifies the query execution time interval. We currently support the units of ns, us, ms, s, m, h, d, w, and its value should not be lower than the minimum threshold configured by the user.")]),e._v(" "),a("li",[a("code",[e._v("<for_interval>")]),e._v(" specifies the time range of each query as "),a("code",[e._v("[now()-<for_interval>, now())")]),e._v(". We currently support the units of ns, us, ms, s, m, h, d, w.")]),e._v(" "),a("li",[a("code",[e._v("<function>")]),e._v(" specifies the aggregate function.")]),e._v(" "),a("li",[a("code",[e._v("<path_prefix>")]),e._v(" and "),a("code",[e._v("<path_suffix>")]),e._v(" are spliced into the queried time series path.")]),e._v(" "),a("li",[a("code",[e._v("<full_path>")]),e._v(" or "),a("code",[e._v("<node_name>")]),e._v(" specifies the result time series path.")]),e._v(" "),a("li",[a("code",[e._v("<group_by_interval>")]),e._v(" specifies the time grouping length. We currently support the units of ns, us, ms, s, m, h, d, w, mo, y.")]),e._v(" "),a("li",[a("code",[e._v("<level>")]),e._v(" refers to grouping according to the "),a("code",[e._v("<level>")]),e._v(" level of the time series, and aggregates all time series below the "),a("code",[e._v("<level>")]),e._v(" level. For the specific semantics of the Group By Level statement and the definition of "),a("code",[e._v("<level>")]),e._v(", see "),a("RouterLink",{attrs:{to:"/UserGuide/Master/IoTDB-SQL-Language/DML-Data-Manipulation-Language.html"}},[e._v("aggregation-by-level")])],1)]),e._v(" "),a("p",[e._v("Note:")]),e._v(" "),a("ul",[a("li",[a("code",[e._v("<for_interval>")]),e._v(","),a("code",[e._v("<every_interval>")]),e._v(" can optionally be specified. If the user does not specify one of them, the value of the unspecified item will be processed equal to "),a("code",[e._v("<group_by_interval>")]),e._v(".\n"),a("ul",[a("li",[e._v("The values of "),a("code",[e._v("<every_interval>")]),e._v(", "),a("code",[e._v("<for_interval>")]),e._v(" and "),a("code",[e._v("<group_by_interval>")]),e._v(" should all be greater than 0.")]),e._v(" "),a("li",[e._v("The value of "),a("code",[e._v("<group_by_interval>")]),e._v(" should be less than the value of "),a("code",[e._v("<for_interval>")]),e._v(", otherwise the system will process the value equal to "),a("code",[e._v("<for_interval>")]),e._v(".")]),e._v(" "),a("li",[e._v("The user should specify the appropriate "),a("code",[e._v("<for_interval>")]),e._v(" and "),a("code",[e._v("<every_interval>")]),e._v(" according to actual needs.\n"),a("ul",[a("li",[e._v("If "),a("code",[e._v("<for_interval>")]),e._v(" is greater than "),a("code",[e._v("<every_interval>")]),e._v(", there will be partial data overlap in each query window. This configuration is not recommended from the perspective of query performance.")]),e._v(" "),a("li",[e._v("If "),a("code",[e._v("<for_interval>")]),e._v(" is less than "),a("code",[e._v("<every_interval>")]),e._v(", there may be uncovered data between each query window.")])])])])]),e._v(" "),a("li",[e._v("For the result series path\n"),a("ul",[a("li",[e._v("The user can choose to specify "),a("code",[e._v("<full_path>")]),e._v(", which is the complete time series path starting with "),a("code",[e._v("root")]),e._v(". The user can use the "),a("code",[e._v("${x}")]),e._v(" variable in the path to represent the node name of "),a("code",[e._v("level = x")]),e._v(" in the original time series. "),a("code",[e._v("x")]),e._v(" should be greater than or equal to 0 and less than or equal to the value of "),a("code",[e._v("<level>")]),e._v("\n(If "),a("code",[e._v("level")]),e._v(" is not specified, it should be less than or equal to the level, i.e. length, of "),a("code",[e._v("<path_prefix>")]),e._v(").")]),e._v(" "),a("li",[e._v("The user can also specify only "),a("code",[e._v("<node_name>")]),e._v(", which is the last node name of the result time series path.\n"),a("ul",[a("li",[e._v("If the user specifies "),a("code",[e._v("<level> = l")]),e._v(", the result time series path generated by the system is "),a("code",[e._v("root.${1}. ... .${l}.<node_name>")])]),e._v(" "),a("li",[e._v("If the user does not specify "),a("code",[e._v("<level>")]),e._v(", let the maximum level of the original time series be "),a("code",[e._v("L")]),e._v(",\nThen the result time series path generated by the system is "),a("code",[e._v("root.${1}. ... .${L-1}.<node_name>")]),e._v(".")])])])])])]),e._v(" "),a("h4",{attrs:{id:"examples"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#examples"}},[e._v("#")]),e._v(" Examples")]),e._v(" "),a("h5",{attrs:{id:"original-data"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#original-data"}},[e._v("#")]),e._v(" Original Data")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-----------------------------+-----+-------------+--------+--------+-----------+----+----------+\n| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|\n+-----------------------------+-----+-------------+--------+--------+-----------+----+----------+\n|root.ln.wf02.wt02.temperature| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n|root.ln.wf02.wt01.temperature| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n|root.ln.wf01.wt02.temperature| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n|root.ln.wf01.wt01.temperature| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n+-----------------------------+-----+-------------+--------+--------+-----------+----+----------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br"),a("span",{staticClass:"line-number"},[e._v("8")]),a("br")])]),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+\n| Time|root.ln.wf02.wt02.temperature|root.ln.wf02.wt01.temperature|root.ln.wf01.wt02.temperature|root.ln.wf01.wt01.temperature|\n+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+\n|2021-05-11T22:18:14.598+08:00| 121.0| 72.0| 183.0| 115.0|\n|2021-05-11T22:18:19.941+08:00| 0.0| 68.0| 68.0| 103.0|\n|2021-05-11T22:18:24.949+08:00| 122.0| 45.0| 11.0| 14.0|\n|2021-05-11T22:18:29.967+08:00| 47.0| 14.0| 59.0| 181.0|\n|2021-05-11T22:18:34.979+08:00| 182.0| 113.0| 29.0| 180.0|\n|2021-05-11T22:18:39.990+08:00| 42.0| 11.0| 52.0| 19.0|\n|2021-05-11T22:18:44.995+08:00| 78.0| 38.0| 123.0| 52.0|\n|2021-05-11T22:18:49.999+08:00| 137.0| 172.0| 135.0| 193.0|\n|2021-05-11T22:18:55.003+08:00| 16.0| 124.0| 183.0| 18.0|\n+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br"),a("span",{staticClass:"line-number"},[e._v("8")]),a("br"),a("span",{staticClass:"line-number"},[e._v("9")]),a("br"),a("span",{staticClass:"line-number"},[e._v("10")]),a("br"),a("span",{staticClass:"line-number"},[e._v("11")]),a("br"),a("span",{staticClass:"line-number"},[e._v("12")]),a("br"),a("span",{staticClass:"line-number"},[e._v("13")]),a("br")])]),a("h5",{attrs:{id:"result-time-series-path-configuration-example"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#result-time-series-path-configuration-example"}},[e._v("#")]),e._v(" Result time series path configuration example")]),e._v(" "),a("p",[e._v("For the above original time series, if the user specifies that the query aggregation level is "),a("code",[e._v("2")]),e._v(", the aggregation function is "),a("code",[e._v("avg")]),e._v(",\nThe user can specify only the last node name of the generated time series in the "),a("code",[e._v("INTO")]),e._v(" clause. If the user specifies it as "),a("code",[e._v("temperature_avg")]),e._v(", the full path generated by the system will be "),a("code",[e._v("root.${1}.${2}.temperature_avg")]),e._v(" .\nThe user can also specify the full path in the "),a("code",[e._v("INTO")]),e._v(" clause, and the user can specify it as "),a("code",[e._v("root.${1}.${2}.temperature_avg")]),e._v(", "),a("code",[e._v("root.ln_cq.${2}.temperature_avg")]),e._v(", "),a("code",[e._v("root.${1}_cq.${2}.temperature_avg")]),e._v(", "),a("code",[e._v("root.${1}.${2}_cq.temperature_avg")]),e._v(" etc.,\nIt can also be specified as "),a("code",[e._v("root.${2}.${1}.temperature_avg")]),e._v(" and others as needed.\nIt should be noted that the "),a("code",[e._v("x")]),e._v(" in "),a("code",[e._v("${x}")]),e._v(" should be greater than or equal to "),a("code",[e._v("1")]),e._v(" and less than or equal to the value of "),a("code",[e._v("<level>")]),e._v("\n(If "),a("code",[e._v("<level>")]),e._v(" is not specified, it should be less than or equal to the length of "),a("code",[e._v("<path_prefix>")]),e._v("). In the above example, "),a("code",[e._v("x")]),e._v(" should be less than or equal to "),a("code",[e._v("2")]),e._v(".")]),e._v(" "),a("h5",{attrs:{id:"create-cq1"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#create-cq1"}},[e._v("#")]),e._v(" Create "),a("code",[e._v("cq1")])]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("CREATE CONTINUOUS QUERY cq1 BEGIN SELECT max_value(temperature) INTO temperature_max FROM root.ln.*.* GROUP BY time(10s) END\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("Query the maximum value of "),a("code",[e._v("root.ln.*.*.temperature")]),e._v(" in the previous 10s every 10s (the results are grouped by 10s),\nand the results will be written to "),a("code",[e._v("root.${1}.${2}.${3}.temperature_max")]),e._v(",\nAs a result, 4 new time series will be generated.")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+---------------------------------+-----+-------------+--------+--------+-----------+----+----------+\n| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|\n+---------------------------------+-----+-------------+--------+--------+-----------+----+----------+\n|root.ln.wf02.wt02.temperature_max| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n|root.ln.wf02.wt01.temperature_max| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n|root.ln.wf01.wt02.temperature_max| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n|root.ln.wf01.wt01.temperature_max| null| root.ln| FLOAT| GORILLA| SNAPPY|null| null|\n+---------------------------------+-----+-------------+--------+--------+-----------+----+----------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br"),a("span",{staticClass:"line-number"},[e._v("8")]),a("br")])]),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-----------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+\n| Time|root.ln.wf02.wt02.temperature_max|root.ln.wf02.wt01.temperature_max|root.ln.wf01.wt02.temperature_max|root.ln.wf01.wt01.temperature_max|\n+-----------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+\n|2021-05-11T22:18:16.964+08:00| 122.0| 68.0| 68.0| 103.0|\n|2021-05-11T22:18:26.964+08:00| 182.0| 113.0| 59.0| 181.0|\n|2021-05-11T22:18:36.964+08:00| 78.0| 38.0| 123.0| 52.0|\n|2021-05-11T22:18:46.964+08:00| 137.0| 172.0| 183.0| 193.0|\n+-----------------------------+---------------------------------+---------------------------------+---------------------------------+---------------------------------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br"),a("span",{staticClass:"line-number"},[e._v("8")]),a("br")])]),a("h5",{attrs:{id:"create-cq2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#create-cq2"}},[e._v("#")]),e._v(" Create "),a("code",[e._v("cq2")])]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("CREATE CONTINUOUS QUERY cq2 RESAMPLE EVERY 20s FOR 20s BEGIN SELECT avg(temperature) INTO temperature_avg FROM root.ln.*.* GROUP BY time(10s), level=2 END\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("Query the average value of "),a("code",[e._v("root.ln.*.*.temperature")]),e._v(" in the previous 20s every 20s (the results are grouped by 10s),\nand the results will be written to "),a("code",[e._v("root.${1}.${2}.temperature_avg")]),e._v(",\nAs a result, 2 new time series will be generated.\nAmong them, "),a("code",[e._v("root.ln.wf02.temperature_avg")]),e._v(" is generated by the aggregation calculation of "),a("code",[e._v("root.ln.wf02.wt02.temperature")]),e._v(" and "),a("code",[e._v("root.ln.wf02.wt01.temperature")]),e._v(",\nand "),a("code",[e._v("root.ln.wf01.temperature_avg")]),e._v(" is generated by the aggregation calculation of "),a("code",[e._v("root.ln.wf01.wt02.temperature")]),e._v(" and "),a("code",[e._v("root.ln.wf01.wt01.temperature")]),e._v(".")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+----------------------------+-----+-------------+--------+--------+-----------+----+----------+\n| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|\n+----------------------------+-----+-------------+--------+--------+-----------+----+----------+\n|root.ln.wf02.temperature_avg| null| root.ln| DOUBLE| GORILLA| SNAPPY|null| null|\n|root.ln.wf01.temperature_avg| null| root.ln| DOUBLE| GORILLA| SNAPPY|null| null|\n+----------------------------+-----+-------------+--------+--------+-----------+----+----------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br")])]),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-----------------------------+----------------------------+----------------------------+\n| Time|root.ln.wf02.temperature_avg|root.ln.wf01.temperature_avg|\n+-----------------------------+----------------------------+----------------------------+\n|2021-05-11T22:18:16.969+08:00| 58.75| 49.0|\n|2021-05-11T22:18:26.969+08:00| 89.0| 112.25|\n|2021-05-11T22:18:36.969+08:00| 42.25| 61.5|\n|2021-05-11T22:18:46.969+08:00| 112.25| 132.25|\n+-----------------------------+----------------------------+----------------------------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br"),a("span",{staticClass:"line-number"},[e._v("8")]),a("br")])]),a("h5",{attrs:{id:"create-cq3"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#create-cq3"}},[e._v("#")]),e._v(" Create "),a("code",[e._v("cq3")])]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("CREATE CONTINUOUS QUERY cq3 RESAMPLE EVERY 20s FOR 20s BEGIN SELECT avg(temperature) INTO root.ln_cq.${2}.temperature_avg FROM root.ln.*.* GROUP BY time(10s), level=2 END\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("p",[e._v("The query mode is the same as "),a("code",[e._v("cq2")]),e._v(",\nand the results will be written to "),a("code",[e._v("root.ln_cq.${2}.temperature_avg")]),e._v(".\nAs a result, 2 new time series will be generated.\nAmong them, "),a("code",[e._v("root.ln_cq.wf02.temperature_avg")]),e._v(" is generated by the aggregation calculation of "),a("code",[e._v("root.ln.wf02.wt02.temperature")]),e._v(" and "),a("code",[e._v("root.ln.wf02.wt01.temperature")]),e._v(",\nand "),a("code",[e._v("root.ln_cq.wf01.temperature_avg")]),e._v(" is generated by the aggregation calculation of "),a("code",[e._v("root.ln.wf01.wt02.temperature")]),e._v(" and "),a("code",[e._v("root.ln.wf01.wt01.temperature")]),e._v(".")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+\n| timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|\n+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+\n|root.ln_cq.wf02.temperature_avg| null| root.ln_cq| DOUBLE| GORILLA| SNAPPY|null| null|\n|root.ln_cq.wf01.temperature_avg| null| root.ln_cq| DOUBLE| GORILLA| SNAPPY|null| null|\n+-------------------------------+-----+-------------+--------+--------+-----------+----+----------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br")])]),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-----------------------------+-------------------------------+-------------------------------+\n| Time|root.ln_cq.wf02.temperature_avg|root.ln_cq.wf01.temperature_avg|\n+-----------------------------+-------------------------------+-------------------------------+\n|2021-05-11T22:18:16.971+08:00| 58.75| 49.0|\n|2021-05-11T22:18:26.971+08:00| 89.0| 112.25|\n|2021-05-11T22:18:36.971+08:00| 42.25| 61.5|\n|2021-05-11T22:18:46.971+08:00| 112.25| 132.25|\n+-----------------------------+-------------------------------+-------------------------------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br"),a("span",{staticClass:"line-number"},[e._v("8")]),a("br")])]),a("h3",{attrs:{id:"show-cq-information"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#show-cq-information"}},[e._v("#")]),e._v(" Show CQ Information")]),e._v(" "),a("h4",{attrs:{id:"syntax-2"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#syntax-2"}},[e._v("#")]),e._v(" Syntax")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("SHOW (CONTINUOUS QUERIES | CQS) \n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("h4",{attrs:{id:"example-result"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#example-result"}},[e._v("#")]),e._v(" Example Result")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("+-------+--------------+------------+----------------------------------------------------------------------------------------+-----------------------------------+\n|cq name|every interval|for interval| query sql| target path|\n+-------+--------------+------------+----------------------------------------------------------------------------------------+-----------------------------------+\n| cq1| 10000| 10000| select max_value(temperature) from root.ln.*.* group by ([now() - 10s, now()), 10s)|root.${1}.${2}.${3}.temperature_max|\n| cq3| 20000| 20000|select avg(temperature) from root.ln.*.* group by ([now() - 20s, now()), 10s), level = 2| root.ln_cq.${2}.temperature_avg|\n| cq2| 20000| 20000|select avg(temperature) from root.ln.*.* group by ([now() - 20s, now()), 10s), level = 2| root.${1}.${2}.temperature_avg|\n+-------+--------------+------------+----------------------------------------------------------------------------------------+-----------------------------------+\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br"),a("span",{staticClass:"line-number"},[e._v("2")]),a("br"),a("span",{staticClass:"line-number"},[e._v("3")]),a("br"),a("span",{staticClass:"line-number"},[e._v("4")]),a("br"),a("span",{staticClass:"line-number"},[e._v("5")]),a("br"),a("span",{staticClass:"line-number"},[e._v("6")]),a("br"),a("span",{staticClass:"line-number"},[e._v("7")]),a("br")])]),a("h3",{attrs:{id:"drop-cq"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#drop-cq"}},[e._v("#")]),e._v(" Drop CQ")]),e._v(" "),a("h4",{attrs:{id:"syntax-3"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#syntax-3"}},[e._v("#")]),e._v(" Syntax")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("DROP (CONTINUOUS QUERY | CQ) <cq_id> \n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("h4",{attrs:{id:"example"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#example"}},[e._v("#")]),e._v(" Example")]),e._v(" "),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("DROP CONTINUOUS QUERY cq3\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("div",{staticClass:"language- line-numbers-mode"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("DROP CQ cq3\n")])]),e._v(" "),a("div",{staticClass:"line-numbers-wrapper"},[a("span",{staticClass:"line-number"},[e._v("1")]),a("br")])]),a("h2",{attrs:{id:"system-parameter-configuration"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#system-parameter-configuration"}},[e._v("#")]),e._v(" System Parameter Configuration")]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",{staticStyle:{"text-align":"left"}},[e._v("Name")]),e._v(" "),a("th",[e._v("Description")]),e._v(" "),a("th",[e._v("Data Type")]),e._v(" "),a("th",[e._v("Default Value")])])]),e._v(" "),a("tbody",[a("tr",[a("td",{staticStyle:{"text-align":"left"}},[a("code",[e._v("continuous_query_execution_thread")])]),e._v(" "),a("td",[e._v("The number of threads in the thread pool that executes continuous query tasks")]),e._v(" "),a("td",[e._v("int")]),e._v(" "),a("td",[e._v("max(1, CPU core number / 2)")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[a("code",[e._v("max_pending_continuous_query_tasks")])]),e._v(" "),a("td",[e._v("The maximum number of continuous query tasks pending in queue")]),e._v(" "),a("td",[e._v("int")]),e._v(" "),a("td",[e._v("64")])]),e._v(" "),a("tr",[a("td",{staticStyle:{"text-align":"left"}},[a("code",[e._v("continuous_query_min_every_interval")])]),e._v(" "),a("td",[e._v("The minimum value of the continuous query execution time interval")]),e._v(" "),a("td",[e._v("duration")]),e._v(" "),a("td",[e._v("1s")])])])])])}),[],!1,null,null,null);t.default=r.exports}}]);