Confused about Retention Polucy and Shards

Hi, I am new to InfluxDB…I have read through documentation but for the life of me, I can not grasp what are RPs and Shards.

Docs say RP is “how long InfluxDB keeps data”…Does this mean if RP is, let’s say, 1 week, the data of that week will be deleted when we enter the 2nd week!?

Shards…“A shard contains the actual encoded and compressed data”…what does this mean?

What is the relationship between RP and Shards? Under which conditions influxdb deletes the data?

Thanks…

1 Like

my understanding is that if your RP is 1 week. shard is 1 day. then one week’s data is saved into 7 shards, if 1 week is passed, influxdb will delete the data in shard 1. and it will delete the data in shard 2 the next day and so forth.

Wow thats bad! I do not want any data be deleted…what can I do?

I currently have the default RP (autogen)

the default RP has infinite duration. no worries, your data won’t be deleted

Duration is associated with a RP - it defines how long the data is held at the database level.

Shard duration on the other hand defines the “length” of a shard i.e how much data (time wise) a shard should hold e.g a week of data, a month etc. So if you have a year worth of data, a 30day shard duration would end up with 12 shards each shard containing a month worth of data.

Arguably a shard is a logical data container.