Data Storage · Study deck

Data Retention and Downsampling

Picture a cold store that keeps one temperature reading each minute.

Data Dora is your guide for this deck.

timeseriesretention
Data Dora, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Design a retention contract that separates raw telemetry, rollups, archives, deletion, and legal holds.
  • Choose downsampling fields that preserve enough evidence for dashboards and investigations.
  • Run a retention dry run before deleting raw data.
  • Explain how late arrivals and rollup refresh windows affect retention safety.
iotclass.org

Major section

Start With the Deletion Request

Telemetry means readings and status sent from equipment for remote use.

  • The storage owner wants to remove old raw data, while the duty team may still need to explain a short heat spike from last month.
  • This opening does not set one lifetime for every reading.
  • Practitioner designs the raw, summary, archive, hold, and approval route.

Key terms

Downsampling
Downsampling is safe only when that evidence survives.
iotclass.org

Major section

Start With the Deletion Request (continued)

Under the Hood examines late arrivals, partition removal, refresh windows, platform commands, and the proof needed before detail is gone.

  • Retention becomes serious the first time someone asks to delete raw readings.
  • Downsampling is safe only when that evidence survives.
  • “Every reading has a time and a cost — decide retention before you decide the database.”.
iotclass.org

Major section

Lifecycle Map

Retention is a sequence of evidence-bearing state changes, not a single expiry number.

  • Rollups preserve declared statistics and coverage, the archive preserves a recoverable copy, and a restore test proves that copy can answer a real query.
  • Deletion is the final governed transition only after every replacement path has evidence.
Retention should be visible as a lifecycle with raw windows, rollups, archive proof, deletion approval, and hold exceptions.
Retention should be visible as a lifecycle with raw windows, rollups, archive proof, deletion approval, and hold exceptions.
iotclass.org

Major section

Downsampling That Preserves Evidence

The mistake is treating the average as the whole story.

  • For IoT telemetry, a useful rollup normally needs fields that preserve coverage, extremes, and quality.
  • Cost: an average alone erases the spikes and sparse coverage that support and safety teams need.
iotclass.org

Major section

Retention Dry Run

A dry run should run before the first automated deletion and before any policy change that shortens raw retention.

  • It should report the raw partitions that would be affected, the rollups that replace them, archive status, restore status, query replay results, hold exceptions, and approval owner.
  • That makes the dry run the operational proof of the lifecycle map.
A retention dry run proves replacement evidence before deletion becomes automatic.
A retention dry run proves replacement evidence before deletion becomes automatic.
iotclass.org

Major section

Platform Patterns

Retention is implemented differently across systems.

  • The review habit should stay stable even when the command changes.
  • TimescaleDB retention commonly uses a background policy that drops chunks older than a chosen interval.
  • Continuous aggregates can preserve summaries after raw chunks expire, but they need refresh windows and late-data rules.

Key terms

Prometheus local storage retention
Prometheus local storage retention is a monitoring setting, usually controlled by retention time or retention size flags.
iotclass.org

Major section

Partition-Aligned Deletion Mechanics

Retention is cheap only when the storage layout gives the engine a whole unit to remove.

  • In time-partitioned systems, old raw data should expire as a complete chunk, partition, shard, or block.
  • One raw day contains 3,456,000,000 points before indexes, replicas, metadata, and compression.
  • Boundary alignment is the trap.

Key terms

If chunks
If chunks are one day long and the approved cutoff is midnight UTC, the engine can drop whole day chunks.
iotclass.org

Major section

Partition-Aligned Deletion Mechanics (continued)

A row-by-row delete for that day has to evaluate billions of row-level decisions.

  • Dropping a one-day chunk removes the partition that already owns that time range.
  • If chunks are one day long and the approved cutoff is midnight UTC, the engine can drop whole day chunks.
  • Monitoring stores have the same idea with blocks: a Prometheus-style store removes old complete blocks, not arbitrary rows inside a block.
iotclass.org

Major section

Common Pitfalls

Storage pressure may start the conversation, but the retention contract belongs to the product, operations, compliance, and support owners.

  • The database job should implement an approved lifecycle decision.
  • An average without sample count, min, max, quality status, and gap markers can hide missing samples and incident spikes.
  • It may make a dashboard cheaper while making the system less explainable.
iotclass.org

Major section

Common Pitfalls (continued)

Backup helps recover the platform.

  • Retention design needs both concepts, but they are not the same artifact.
  • Retention commands and scopes differ across TimescaleDB, InfluxDB versions, Prometheus, managed services, and self-hosted deployments.
  • Teach the evidence model first, then confirm the exact implementation docs for the system being used.
iotclass.org

Major section

Summary

Data retention is the lifecycle discipline behind time-series systems.

  • It decides how long raw detail remains, what summaries replace it, what archive can be restored, which data is held, and when deletion is approved.
  • The strongest retention design is evidence-first: preserve quality in rollups, dry-run every deletion policy, restore a sample before trusting an archive, make holds visible to automation, and record owner approval.
  • That keeps storage manageable without letting quality drift or incident evidence disappear.
iotclass.org

Deck summary

Key takeaways

Telemetry means readings and status sent from equipment for remote use.

  • Under the Hood examines late arrivals, partition removal, refresh windows, platform commands, and the proof needed before detail is gone.
  • Retention is a sequence of evidence-bearing state changes, not a single expiry number.
  • The mistake is treating the average as the whole story.
  • A dry run should run before the first automated deletion and before any policy change that shortens raw retention.
iotclass.org

Retrieval practice

Recall check 1 of 4

Data Dora says: answer from memory, then check your reasoning.

Q1Which retention release criterion is strongest before deleting raw telemetry?

AThe deletion job runs without throwing an error.
BRollups, restore, holds, and owner approval all pass.
CThe dashboard loads faster after old raw data disappears.
DThe database vendor supports a retention command.
Show answer

Answer: B Retention is safe only when the replacement evidence, restore path, query behavior, hold status, and owner decision are visible.

iotclass.org

Retrieval practice

Recall check 2 of 4

Data Dora says: answer from memory, then check your reasoning.

Q2Why does a time-partitioned store use chunk- or partition-drop deletion instead of a large DELETE WHERE time < cutoff job?

ABecause a row-level DELETE leaves index entries that prevent the deleted readings from disappearing from queries.
BBecause dropping an aligned time partition avoids billions of row-level delete decisions.
CBecause the partition boundary also establishes which archived records are safe to restore.
DBecause dropping chunks changes the raw sensor sampling rate.
Show answer

Answer: B Retention is efficient when policy cutoffs align with chunks, partitions, or blocks; row-by-row deletes are the fallback to avoid.

iotclass.org

Retrieval practice

Recall check 3 of 4

Data Dora says: answer from memory, then check your reasoning.

Q3Place each retention artifact where it lives so you can delete data without destroying required evidence.

ARaw Window
BRollup Proof
CArchive Restore
DDeletion Approval
Show answer

Answer: A Place source protection, substitute or restore proof, and authorization correctly so you can make retention release auditable.

Q4Complete the retention decision record with the evidence fields required before raw data can be deleted.

Araw_window: observed_at_range, late_arrival_window, hold_scope
Braw_window: page_theme, font_size, icon_color
Craw_window: delete_everything_immediately
Draw_window: unknown_timestamp_source
Show answer

Answer: A

iotclass.org

Retrieval practice

Recall check 4 of 4

Data Dora says: answer from memory, then check your reasoning.

Q5A team wants to shorten raw telemetry retention because storage is growing. What should they do before changing the deletion policy?

AChange the retention interval immediately because old data is probably less useful.
BRetain averages as the replacement evidence, since they preserve long-term trends while reducing storage.
CRely on a backup instead of an archive because both contain old data.
DRun a dry run, prove rollup coverage, restore a sample, and get owner approval.
Show answer

Answer: D Shortening raw retention changes what evidence remains available, so the release packet must prove the replacement path.

iotclass.org

Print reference

Answers

Answer key.

  1. B · Retention is safe only when the replacement evidence, restore path, query behavior, hold status, and owner decision are visible.
  2. B · Retention is efficient when policy cutoffs align with chunks, partitions, or blocks; row-by-row deletes are the fallback to avoid.
  3. A · Place source protection, substitute or restore proof, and authorization correctly so you can make retention release auditable.
  4. A
  5. D · Shortening raw retention changes what evidence remains available, so the release packet must prove the replacement path.
iotclass.org