跳至主要內容

...大约 2 分钟

时间分区

主要功能

时间分区按照时间分割数据,一个时间分区用于保存某个时间范围内的所有数据。时间分区编号使用自然数表示,0 表示 1970 年 1 月 1 日,每隔 partition_interval 毫秒后加一。数据通过计算 timestamp / partition_interval 得到自己所在的时间分区编号,主要配置项如下所示:

  • time_partition_interval
名字time_partition_interval
描述Database 分区的时间段长度,用户指定的 database 下会使用该时间段进行分区,单位:毫秒
类型Int64
默认值604800000
改后生效方式仅允许在第一次启动服务前修改

配置示例

开启时间分区功能,并设置 partition_interval 为 86400000(一天),则数据的分布情况如下图所示:

time partition example
  • 插入一条时间戳为 0 的数据,计算 0 / 86400000 = 0,则该数据会被存储到 0 号文件夹下的TsFile中

  • 插入一条时间戳为 1609459200010 的数据,计算 1609459200010 / 86400000 = 18628,则该数据会被存储到 18628 号文件夹下的TsFile中

使用建议

使用时间分区功能时,建议同时打开 Memtable 的定时刷盘功能,共 6 个相关配置参数(详情见 timed_flush配置项)。

  • enable_timed_flush_unseq_memtable: 是否开启乱序 Memtable 的定时刷盘,默认打开。

  • enable_timed_flush_seq_memtable: 是否开启顺序 Memtable 的定时刷盘,默认关闭。应当在开启时间分区后打开,定时刷盘非活跃时间分区下的 Memtable,为定时关闭 TsFileProcessor 作准备。

Copyright © 2024 The Apache Software Foundation.
Apache IoTDB, IoTDB, Apache, the Apache feather logo, and the Apache IoTDB project logo are either registered trademarks or trademarks of The Apache Software Foundation in all countries

Have a question? Connect with us on QQ, WeChat, or Slack. Join the community now.