← Back to the chapter · Previous detail · Next detail →

Technical detail · Data Retention and Downsampling

TimescaleDB-Style Policies

TimescaleDB retention commonly uses a background policy that drops chunks older than a chosen interval. That command is powerful because it deletes data. Use it after rollup, archive, restore, and hold checks pass.

-- Example: drop raw chunks after the approved raw-retention window.
SELECT add_retention_policy(
  'readings',
  drop_after => INTERVAL '30 days',
  if_not_exists => true
);

Continuous aggregates can preserve summaries after raw chunks expire, but they need refresh windows and late-data rules. The release review should prove that a late reading inside the allowed correction window refreshes the affected buckets before the raw source disappears.

Confirm the deployed version against Tiger Data data retention. Review the scheduled chunk deletion command in add_retention_policy and refresh behavior in continuous aggregates.

← Back to the chapter · Previous detail · Next detail →