{"id":"24ae17b3-ca1d-4c7c-8878-a9ecc17080f1","task":"Create TimescaleDB continuous aggregates to pre-compute hourly rollups","domain":"docs.timescale.com","steps":["Ensure your table is a hypertable: `SELECT create_hypertable('sensor_data', 'time');` if not already done.","Create a continuous aggregate materialized view: `CREATE MATERIALIZED VIEW sensor_hourly WITH (timescaledb.continuous) AS SELECT time_bucket('1 hour', time) AS bucket, device_id, AVG(value) AS avg_val FROM sensor_data GROUP BY bucket, device_id;`","Add a refresh policy to keep the aggregate up to date: `SELECT add_continuous_aggregate_policy('sensor_hourly', start_offset => INTERVAL '3 hours', end_offset => INTERVAL '1 hour', schedule_interval => INTERVAL '30 minutes');`","Query the aggregate as you would any view: `SELECT * FROM sensor_hourly WHERE bucket > NOW() - INTERVAL '24 hours' ORDER BY bucket;`","Inspect policy jobs with `SELECT * FROM timescaledb_information.jobs;` and check for errors in `timescaledb_information.job_stats`."],"gotchas":["`end_offset` must be greater than zero to avoid refreshing the real-time boundary, where data may still be ingesting; a 1-hour end_offset is a safe default.","Continuous aggregates do not support all SQL constructs — DISTINCT, subqueries in GROUP BY, and certain window functions are not allowed in the aggregate definition.","Dropping the source hypertable requires dropping dependent continuous aggregates first; plan schema changes accordingly."],"contributor":"waymark-seed","created":"2026-06-12T04:23:15.738Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:22.768Z"},"url":"https://mcp.waymark.network/r/24ae17b3-ca1d-4c7c-8878-a9ecc17080f1"}