# 查看庫(kù)存儲(chǔ)規(guī)則
> SHOW RETENTION POLICIES ON spider_record;
[out]:
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 720h0m0s 168h0m0s 1 true
# 修改存儲(chǔ)規(guī)則
> ALTER RETENTION POLICY autogen ON spider_record DURATION 720h;
# 設(shè)為默認(rèn)
> ALTER RETENTION POLICY autogen ON spider_record DEFAULT;
# 刪除規(guī)則
> drop retention POLICY rule_01 ON spider_record;
#創(chuàng)建規(guī)則
> 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--名稱(chēng)呕缭,此示例名稱(chēng)為 autogen
duration--持續(xù)時(shí)間庐冯,0代表無(wú)限制
shardGroupDuration--shardGroup的存儲(chǔ)時(shí)間,shardGroup是InfluxDB的一個(gè)基本儲(chǔ)存結(jié)構(gòu)惫叛,應(yīng)該大于這個(gè)時(shí)間的數(shù)據(jù)在查詢(xún)效率上應(yīng)該有所降低。
replicaN--全稱(chēng)是REPLICATION锻霎,副本個(gè)數(shù)
default--是否是默認(rèn)策略
DOCUMENT: http://www.reibang.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.