diff --git a/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md b/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md index acd76954f9f7dabf173a1f17d63aba62497c354f..d4946987527af9dd1378bc8d9fbf47b365015b67 100644 --- a/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md +++ b/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md @@ -20,7 +20,6 @@ CREATE TABLE () [TAGS|ATTRIBUTES] () PRIMARY [TAGS|ATTRIBUTES] () [RETENTIONS ] -[DICT ENCODING] [COMMENT [=] <'comment_text'>] [WITH HASH()]; ``` @@ -30,7 +29,7 @@ PRIMARY [TAGS|ATTRIBUTES] () :::warning 说明 - 目前,时序表名、列名和标签名称不支持中文字符。 -- 配置可选参数时,必须严格按照 `[RETENTIONS ] [DICT ENCODING] [COMMENT [=] <'comment_text'>] [WITH HASH()]` 的顺序,否则系统将会报错。 +- 配置可选参数时,必须严格按照 `[RETENTIONS ] [COMMENT [=] <'comment_text'>] [WITH HASH()]` 的顺序,否则系统将会报错。 - 3.0.0 版本中,表活跃时间和分区间隔的配置不会生效。 ::: @@ -41,7 +40,6 @@ PRIMARY [TAGS|ATTRIBUTES] () | `tag_list`| 标签列表,支持添加一个或多个标签定义,最多可指定 `128` 个标签。标签定义包含标签名、数据类型和注释信息。
- 标签名的最大长度为 128 字节,支持指定 NOT NULL,默认为空值。不支持 TIMESTAMP、TIMESTAMPTZ、NVARCHAR 和 GEOMETRY 数据类型。
- 支持在 nullable 条件之后添加标签列的注释信息。 | | `primary_tag_list`| 主标签列表,支持添加一个或多个主标签名称,最多可指定 `4` 个。主标签必须包含在标签列表内且指定为 NOT NULL,不支持浮点类型和除 VARCHAR 之外的变长数据类型。VARCHAR 类型长度默认 `64` 字节,最大长度为 `128` 字节。| | `keep_duration` | 可选参数,设置表的数据生命周期。数据超过此时长后将被系统自动清除。
默认值: `0s`(永久保留)
时间单位:
- 秒:`s` 或 `second`
- 分钟:`m` 或 `minute`
- 小时:`h` 或 `hour`
- 天:`d` 或 `day`
- 周:`w` 或 `week`
- 月:`mon` 或 `month`
- 年:`y` 或 `year`
取值范围:正整数,上限为 1000 年
**说明:**
- 表级设置优先于库级设置。
- 保留时长越长,存储空间占用越大,请根据业务需求合理配置。
- 如果待写入的数据已超过生命周期限制,系统会直接丢弃该数据,不予写入。| -| `DICT ENCODING`| 可选参数,启用字符串的字典编码功能,提升字符串数据的压缩能力。表中存储的字符串数据重复率越高,压缩优化效果越明显。该功能只适用于 CHAR 和 VARCHAR 长度小于等于 `1023` 的字符串,且只能在建表时开启。开启后不支持禁用。 | | `[COMMENT [=] <'comment_text'>` | 可选项,定义表的注释信息。 | | `hash_value`| 可选参数,用于定义分布式集群中 HASH 环的大小,决定最大 Range 分片数量。例如 HASH(100) 表示最多可产生 100 个不同的 Range 分片。

默认值为 2000,表示最多可产生 2000 个 Range 分片。支持设置范围为 [1,50000]。

性能影响:HASH 值过小时将导致多个设备的数据集中在少数 Range 中,形成写入热点,HASH 值过大时则会导致 Range 数量过多,增加管理开销。

推荐配置:建议根据预期设备数量选择合适的 HASH 值:
- 设备数 ≤ 1,000:HASH 值 < 20
- 设备数 ≤ 50,000:HASH 值 < 2,000
- 设备数 ≤ 1,000,000:HASH 值 < 10,000| @@ -102,14 +100,6 @@ PRIMARY [TAGS|ATTRIBUTES] () (1 row) ``` -- 创建时序表并开启字符串字典编码。 - - 以下示例创建一个名为 `water` 的时序表并开启字符串字典编码。 - - ```sql - CREATE TABLE water (ts TIMESTAMP NOT NULL, value FLOAT) TAGS (sensor_id INT NOT NULL) PRIMARY TAGS (sensor_id) DICT ENCODING; - ``` - - 创建时序表并为表及其数据列和标签列添加注释信息。 以下示例创建一个名为 `device_info` 的时序表并为表及其数据列和标签列添加注释信息。 diff --git a/en/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md b/en/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md index 2057042c4b0015c37edd68b4ff94153d8d401834..287d4ae80b2dce4111c038935cea50f0fbea0fba 100644 --- a/en/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md +++ b/en/db-administration/db-object-mgmt/ts-db/table-mgmt-ts.md @@ -22,7 +22,6 @@ CREATE TABLE () [TAGS|ATTRIBUTES] () PRIMARY [TAGS|ATTRIBUTES] () [RETENTIONS ] -[DICT ENCODING] [COMMENT [=] <'comment_text'>] [WITH HASH()]; ``` @@ -32,7 +31,7 @@ PRIMARY [TAGS|ATTRIBUTES] () :::warning Note - Currently, the table name, column name, and tag name do not support Chinese characters. -- The optional parameters must be configured in an order of `[RETENTIONS ] [DICT ENCODING] [COMMENT [=] <'comment_text'>] [WITH HASH()]`. Otherwise, the system returns an error. +- The optional parameters must be configured in an order of `[RETENTIONS ] [COMMENT [=] <'comment_text'>] [WITH HASH()]`. Otherwise, the system returns an error. - In version 3.0.0, the `activetime` and `partition interval` configurations are ignored. ::: @@ -44,7 +43,6 @@ PRIMARY [TAGS|ATTRIBUTES] () | `tag_list`| A comma-separated list of tags. You can specify one or more tags. Each table supports up to 128 tags. Each tag requires a name and data type. The tag name supports up to 128 bytes. You can set the data type to NOT NULL. By default, the data type is set to NULL. KWDB does not support setting TIMESTAMP, TIMESTAMPTZ, NVARCHAR or GEOMETRY data types for time-series tables.
Support adding comments to tag columns after the nullable condition. | | `primary_tag_list`| A comma-separated list of primary tags. You can specify one or more primary tags. Each table supports up to 4 primary tags. Primary tags must be included in the list of tags and set to NOT NULL. Currently, primary tags does not support floating-point and variable-length data types, except for the VARCHAR data type. By default, a VARCHAR-typed data length is `64` bytes. The maximum of a VARCHAR-typed data length is `128` bytes. | | `keep_duration`| Optional. Defines the data retention period for the database. Data older than this duration will be automatically purged.
Default: `0s` (retain indefinitely)
Time units:
- Seconds: `s` or `second`
- Minutes: `m` or `minute`
- Hours: `h` or `hour`
- Days: `d` or `day`
- Weeks: `w` or `week`
- Months: `mon` or `month`
- Years: `y` or `year`
Valid range: Positive integer up to 1000 years
Note:
- Table-level retention settings override database-level settings.
- Longer retention periods consume more storage. Configure based on your business needs.
- Data that already exceeds the retention period at write time will be rejected and not stored. | -| `DICT ENCODING`| Optional. Enable dictionary encoding to improve the compression capability of STRING-typed data. The higher the repetition rate of the STRING-typed data is, the better the data is compressed. This function is only applied to CHAR- and VARCHAR-typed data whose length is less than or equal to `1023`. You can only enable it when creating a table. Once enabled, you cannot disable it. | | `comment_text` | Optional. Specify the comment to be associated to the table.| | `hash_value`| Optional. Defines the HASH ring size in a distributed cluster, which determines the maximum number of data ranges. For example, `HASH(100)` allows up to 100 distinct ranges.

Default: 2000 (up to 2000 ranges)
Valid range: [1, 50000]

Performance considerations:
- Too small: Data from multiple devices concentrates in fewer ranges, causing write hotspots
- Too large: Excessive ranges increase management overhead

Recommended values based on device count:
- ≤ 1,000 devices: `hash_value` < 20
- ≤ 50,000 devices: `hash_value` < 2,000
- ≤ 1,000,000 devices: `hash_value` < 10,000| @@ -101,12 +99,6 @@ PRIMARY [TAGS|ATTRIBUTES] () (1 row) ``` -- Create a table and enable dictionary encoding. - - ```sql - CREATE TABLE water (ts TIMESTAMP NOT NULL, value FLOAT) TAGS (sensor_id INT NOT NULL) PRIMARY TAGS (sensor_id) DICT ENCODING; - ``` - - Create a table and associate comments to the data columns, the tag columns and the table. This example creates a table named `device_info` and associates comments to the data columns, the tag columns and the table. diff --git a/en/sql-reference/ddl/ts-db/ts-table.md b/en/sql-reference/ddl/ts-db/ts-table.md index 125d217ffd22879920fa3ca4033c318d45b8a0eb..6d3c2bce28a1f99f78bc76f30e66a6a7e641d9f5 100644 --- a/en/sql-reference/ddl/ts-db/ts-table.md +++ b/en/sql-reference/ddl/ts-db/ts-table.md @@ -24,7 +24,7 @@ The user must be a member of the `admin` role or have been granted the `CREATE` :::warning Note - Currently, the table name, column name, and tag name do not support Chinese characters. -- The optional parameters must be configured in an order of `[RETENTIONS ] [DICT ENCODING] [COMMENT [=] <'comment_text'>]`. Otherwise, the system returns an error. +- The optional parameters must be configured in an order of `[RETENTIONS ] [COMMENT [=] <'comment_text'>]`. Otherwise, the system returns an error. - In version 3.0.0, the `activetime` and `partition interval` configurations are ignored. ::: @@ -36,7 +36,6 @@ The user must be a member of the `admin` role or have been granted the `CREATE` | `tag_list`| A comma-separated list of tags. You can specify one or more tags. Each table supports up to 128 tags. Each tag requires a name and data type. The tag name supports up to 128 bytes. You can set the data type to NOT NULL. By default, the data type is set to NULL. KWDB does not support setting TIMESTAMP, TIMESTAMPTZ, NVARCHAR or GEOMETRY data types for time-series tables.
Support adding comments to tag columns after the nullable condition. | | `primary_tag_list`| A comma-separated list of primary tags. You can specify one or more primary tags. Each table supports up to 4 primary tags. Primary tags must be included in the list of tags and set to NOT NULL. Currently, primary tags does not support floating-point and variable-length data types, except for the VARCHAR data type. By default, a VARCHAR-typed data length is `64` bytes. The maximum of a VARCHAR-typed data length is `128` bytes. | | `keep_duration`| Optional. Defines the data retention period for the database. Data older than this duration will be automatically purged.
Default: `0s` (retain indefinitely)
Time units:
- Seconds: `s` or `second`
- Minutes: `m` or `minute`
- Hours: `h` or `hour`
- Days: `d` or `day`
- Weeks: `w` or `week`
- Months: `mon` or `month`
- Years: `y` or `year`
Valid range: Positive integer up to 1000 years
Note:
- Table-level retention settings override database-level settings.
- Longer retention periods consume more storage. Configure based on your business needs.
- Data that already exceeds the retention period at write time will be rejected and not stored. | -| `DICT ENCODING`| Optional. Enable dictionary encoding to improve the compression capability of STRING-typed data. The higher the repetition rate of the STRING-typed data is, the better the data is compressed. This function is only applied to CHAR- and VARCHAR-typed data whose length is less than or equal to `1023`. You can only enable it when creating a table. Once enabled, you cannot disable it. | | `comment_text` | Optional. Specify the comment to be associated to the table.| | `hash_value`| Optional. Defines the HASH ring size in a distributed cluster, which determines the maximum number of data ranges. For example, `HASH(100)` allows up to 100 distinct ranges.

Default: 2000 (up to 2000 ranges)
Valid range: [1, 50000]

Performance considerations:
- Too small: Data from multiple devices concentrates in fewer ranges, causing write hotspots
- Too large: Excessive ranges increase management overhead

Recommended values based on device count:
- ≤ 1,000 devices: `hash_value` < 20
- ≤ 50,000 devices: `hash_value` < 2,000
- ≤ 1,000,000 devices: `hash_value` < 10,000| @@ -93,12 +92,6 @@ The user must be a member of the `admin` role or have been granted the `CREATE` (1 row) ``` -- Create a table and enable dictionary encoding. - - ```sql - CREATE TABLE water (ts TIMESTAMP NOT NULL, value FLOAT) TAGS (sensor_id INT NOT NULL) PRIMARY TAGS (sensor_id) DICT ENCODING; - ``` - - Create a table and associate comments to the data columns, the tag columns and the table. This example creates a table named `device_info` and associates comments to the data columns, the tag columns and the table. diff --git a/sql-reference/ddl/ts-db/ts-table.md b/sql-reference/ddl/ts-db/ts-table.md index 2e0d89aeb4dc72def7d206143a642a0e3a9405d2..a4557cfc244c29d3ca8db0ec58270081859cbd9a 100644 --- a/sql-reference/ddl/ts-db/ts-table.md +++ b/sql-reference/ddl/ts-db/ts-table.md @@ -22,7 +22,7 @@ id: ts-table :::warning 说明 - 目前,时序表名、列名和标签名称不支持中文字符。 -- 配置可选参数时,必须严格按照 `[RETENTIONS ] [DICT ENCODING] [COMMENT [=] <'comment_text'>] [WITH HASH()]` 的顺序,否则系统将会报错。 +- 配置可选参数时,必须严格按照 `[RETENTIONS ] [COMMENT [=] <'comment_text'>] [WITH HASH()]` 的顺序,否则系统将会报错。 - 3.0.0 版本中,表活跃时间和分区间隔的配置不会生效。 ::: @@ -34,7 +34,6 @@ id: ts-table | `tag_list`| 标签列表,支持添加一个或多个标签定义,最多可指定 `128` 个标签。标签定义包含标签名、数据类型和注释信息。
- 标签名的最大长度为 128 字节,支持指定 NOT NULL,默认为空值。不支持 TIMESTAMP、TIMESTAMPTZ、NVARCHAR 和 GEOMETRY 数据类型。
- 支持在 nullable 条件之后添加标签列的注释信息。 | | `primary_tag_list`| 主标签列表,支持添加一个或多个主标签名称,最多可指定 `4` 个。主标签必须包含在标签列表内且指定为 NOT NULL,不支持浮点类型和除 VARCHAR 之外的变长数据类型。VARCHAR 类型长度默认 `64` 字节,最大长度为 `128` 字节。| | `keep_duration` | 可选参数,设置表的数据生命周期。数据超过此时长后将被系统自动清除。
默认值: `0s`(永久保留)
时间单位:
- 秒:`s` 或 `second`
- 分钟:`m` 或 `minute`
- 小时:`h` 或 `hour`
- 天:`d` 或 `day`
- 周:`w` 或 `week`
- 月:`mon` 或 `month`
- 年:`y` 或 `year`
取值范围:正整数,上限为 1000 年
**说明:**
- 表级设置优先于库级设置。
- 保留时长越长,存储空间占用越大,请根据业务需求合理配置。
- 如果待写入的数据已超过生命周期限制,系统会直接丢弃该数据,不予写入。| -| `DICT ENCODING`| 可选参数,启用字符串的字典编码功能,提升字符串数据的压缩能力。表中存储的字符串数据重复率越高,压缩优化效果越明显。该功能只适用于 CHAR 和 VARCHAR 长度小于等于 `1023` 的字符串,且只能在建表时开启。开启后不支持禁用。 | | `[COMMENT [=] <'comment_text'>` | 可选参数,定义表的注释信息。 | | `hash_value`| 可选参数,用于定义分布式集群中 HASH 环的大小,决定最大 Range 分片数量。例如 HASH(100) 表示最多可产生 100 个不同的 Range 分片。

默认值为 2000,表示最多可产生 2000 个 Range 分片。支持设置范围为 [1,50000]。

性能影响:HASH 值过小时将导致多个设备的数据集中在少数 Range 中,形成写入热点,HASH 值过大时则会导致 Range 数量过多,增加管理开销。

推荐配置:建议根据预期设备数量选择合适的 HASH 值:
- 设备数 ≤ 1,000:HASH 值 < 20
- 设备数 ≤ 50,000:HASH 值 < 2,000
- 设备数 ≤ 1,000,000:HASH 值 < 10,000 | @@ -95,14 +94,6 @@ id: ts-table (1 row) ``` -- 创建时序表并开启字符串字典编码。 - - 以下示例创建一个名为 `water` 的时序表并开启字符串字典编码。 - - ```sql - CREATE TABLE water (ts TIMESTAMP NOT NULL, value FLOAT) TAGS (sensor_id INT NOT NULL) PRIMARY TAGS (sensor_id) DICT ENCODING; - ``` - - 创建时序表并为表及其数据列和标签列添加注释信息。 以下示例创建一个名为 `device_info` 的时序表并为表及其数据列和标签列添加注释信息。 diff --git a/static/sql-reference/create_table_ts.png b/static/sql-reference/create_table_ts.png index 15ff1a12c6273823a379c5db1e219dadf99a2817..4af16bea633494da4ff000a8434728843bca1713 100644 Binary files a/static/sql-reference/create_table_ts.png and b/static/sql-reference/create_table_ts.png differ