Time-series queries
Store timestamped records and summarize them with ordinary SQL.
Example
Section titled “Example”CREATE TABLE docs_readings (id BIGINT PRIMARY KEY, measured_at TIMESTAMP, value BIGINT);INSERT INTO docs_readings VALUES (1, '2026-01-01 12:10:00', 10), (2, '2026-01-01 12:20:00', 30);SELECT DATE_TRUNC('hour', measured_at) AS hour, AVG(value) AS meanFROM docs_readings GROUP BY DATE_TRUNC('hour', measured_at)ORDER BY hour;Behavior
Section titled “Behavior”Both readings fall in the same hour and have a mean of 20. Define your timezone and missing-data policy explicitly. A missing interval is different from a zero-valued measurement. Plan retention as an application or operational policy rather than assuming rows expire automatically.
Related
Section titled “Related”This site uses Google Analytics cookies to count visits. Privacy · License