| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| --> |
| |
| # 数据存活时间(TTL) |
| |
| IoTDB 支持对存储组级别设置数据存活时间(TTL),这使得 IoTDB 可以定期、自动地删除一定时间之前的数据。合理使用 TTL |
| 可以帮助您控制 IoTDB 占用的总磁盘空间以避免出现磁盘写满等异常。并且,随着文件数量的增多,查询性能往往随之下降, |
| 内存占用也会有所提高。及时地删除一些较老的文件有助于使查询性能维持在一个较高的水平和减少内存资源的占用。 |
| |
| ## 设置 TTL |
| |
| 设置 TTL 的 SQL 语句如下所示: |
| ``` |
| IoTDB> set ttl to root.ln 3600000 |
| ``` |
| 这个例子表示在`root.ln`存储组中,只有最近一个小时的数据将会保存,旧数据会被移除或不可见。 |
| |
| ## 取消 TTL |
| |
| 取消 TTL 的 SQL 语句如下所示: |
| |
| ``` |
| IoTDB> unset ttl to root.ln |
| ``` |
| |
| 取消设置 TTL 后,存储组`root.ln`中所有的数据都会被保存。 |
| |
| ## 显示 TTL |
| |
| 显示 TTL 的 SQL 语句如下所示: |
| |
| ``` |
| IoTDB> SHOW ALL TTL |
| IoTDB> SHOW TTL ON StorageGroupNames |
| ``` |
| |
| SHOW ALL TTL 这个例子会给出所有存储组的 TTL。 |
| SHOW TTL ON root.group1,root.group2,root.group3 这个例子会显示指定的三个存储组的 TTL。 |
| 注意:没有设置 TTL 的存储组的 TTL 将显示为 null。 |