Prompt
How do I keep 12 months of sensor data without storage exploding?
Latest observation
To keep 12 months of sensor data without storage exploding, use a tiered retention strategy instead of storing every reading at full resolution forever.
1) Store recent data at full resolution, older data summarized
Keep raw readings only for a short window, then roll them up:
- Last 7–30 days: full precision, raw samples
- 1–6 months: 1-minute or 5-minute aggregates
- 6–12 months: hourly or daily aggregates
- Beyond 12 months: delete or keep only key summaries
Typical aggregates:
- average
- min / max
- count
- standard deviation
- last value
This gives you trend visibility without keeping every point.
2) Downsample by time bucket
Instead of one row per sensor reading, compress into time buckets:
Example:
- 1 reading/sec = 86,400 points/day
- 1-minute buckets = 1,440 points/day
- 1-hour buckets = 24 points/day
That’s a huge reduction.
3) Use a time-series database or optimized schema
If you’re using a relational DB, use:
- partitioning by date
- indexes only on needed fields
- compression if available
Time-series systems often handle this better:
- TimescaleDB
- InfluxDB
- ClickHouse
- Apache Druid
4) Compress and avoid storing redundant data
- Use integer timestamps instead of verbose datetime strings
- Store values in compact numeric types
- Avoid duplicate metadata in every row
- Use compression at the database or storage layer
5) Separate raw and derived data
Keep:
- raw data for debugging / audits
- aggregated data for dashboards and analytics
This lets you delete raw data sooner while preserving business value.
6) Apply retention policies automatically
Set automatic jobs to:
- aggregate old data
- move it to colder storage
- delete expired raw data
Don’t rely on manual cleanup.
7) Sample intelligently if needed
If you have very high-frequency sensors, you may not need every sample:
- keep every sample during events/anomalies
- sample sparsely when values are stable
- burst-record when thresholds are crossed
A practical example
For a sensor reading every second:
- Raw for 14 days
- 1-minute aggregates for 90 days
- 1-hour aggregates for 12 months
- Delete raw after aggregation
This can reduce storage by orders of magnitude.
Rule of thumb
Ask:
- What do I need for debugging?
- What do I need for reports?
- What do I need for compliance?
Then keep only the data needed at the right granularity.
If you want, I can help you design a retention policy for your specific sensor rate and storage size.