# 查看库存储规则
> SHOW RETENTION POLICIES ON spider_record;
[out]:
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 720h0m0s 168h0m0s 1 true
# 修改存储规则
> ALTER RETENTION POLICY autogen ON spider_record DURATION 720h;
# 设为默认
> ALTER RETENTION POLICY autogen ON spider_record DEFAULT;
# 删除规则
> drop retention POLICY rule_01 ON spider_record;
#创建规则
> CREATE RETENTION POLICY "rule_01" ON spider_record DURATION 360h REPLICATION 1;
> SHOW RETENTION POLICIES ON spider_record;
[out]
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 0s 168h0m0s 1 true
rule_01 360h0m0s 24h0m0s 1 false
# 字段含义
name--名称,此示例名称为 autogen
duration--持续时间,0代表无限制
shardGroupDuration--shardGroup的存储时间,shardGroup是InfluxDB的一个基本储存结构,应该大于这个时间的数据在查询效率上应该有所降低。
replicaN--全称是REPLICATION,副本个数
default--是否是默认策略
DOCUMENT: //www.greatytc.com/writer#/notebooks/31848360/notes/42196019/preview
InfluxDB stores data in shard groups. A single shard group covers a specific time interval; InfluxDB determines that time interval by looking at the DURATION
of the relevant retention policy (RP). The table below outlines the default relationship between the DURATION
of an RP and the time interval of a shard group:
RP duration | Shard group interval |
---|---|
< 2 days | 1 hour |
>= 2 days and <= 6 months | 1 day |
> 6 months | 7 days |
Users can also configure the shard group duration with the CREATE RETENTION POLICY
and ALTER RETENTION POLICY
statements. Check your retention policy’s shard group duration with the SHOW RETENTION POLICY
statement.