A retention policy automatically removes time-series chunks containing data older than a configured age. On a hypertable, TimescaleDB schedules a job to drop chunks that contain only expired data. section 9.4
Configure retention around the data lifecycle:
- Create a 30-day policy with add_retention_policy('watch.heart_rate_measurements', INTERVAL '30 days'). section 9.4
- Change the schedule_interval to run cleanup every 12 hours instead of daily. section 9.4
- Apply the same mechanism to continuous aggregates, such as keeping aggregate chunks for seven days. section 9.6.2
Protect sample data before testing
A dataset dated 2024 and 2025 may fall entirely outside a 30-day window if the policy is created later. Test carefully: the policy can remove all records from the example measurements table. section 9.4
SELECT add_retention_policy( 'watch.heart_rate_measurements', INTERVAL '30 days');
Inspect the basic SQL command for adding a 30-day retention policy to a hypertable. section 9.4









