# 查看庫存儲規(guī)則
> SHOW RETENTION POLICIES ON spider_record;
[out]:
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 720h0m0s 168h0m0s 1 true
# 修改存儲規(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--名稱,此示例名稱為 autogen
duration--持續(xù)時間,0代表無限制
shardGroupDuration--shardGroup的存儲時間,shardGroup是InfluxDB的一個基本儲存結(jié)構(gòu),應(yīng)該大于這個時間的數(shù)據(jù)在查詢效率上應(yīng)該有所降低。
replicaN--全稱是REPLICATION,副本個數(shù)
default--是否是默認(rèn)策略
DOCUMENT: http://www.itdecent.cn/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.