Time-Series Quick Start Guide
Time-Series Quick Start Guide
Time to Complete: 10 minutes Prerequisites: HeliosDB installed
Overview
This guide will help you get started with HeliosDB’s time-series capabilities. You will learn to:
- Create a time-series table
- Write time-series data points
- Query time ranges
- Configure retention policies
- Set up downsampling
Using SQL Interface
HeliosDB supports time-series operations through SQL:
Create Time-Series Table
-- Create a time-series optimized tableCREATE TABLE sensor_readings ( timestamp TIMESTAMPTZ NOT NULL, sensor_id VARCHAR(64) NOT NULL, temperature DOUBLE PRECISION, humidity DOUBLE PRECISION) WITH ( partition_by = 'DAY', retention = '30 days', compression = 'gorilla');Insert Data
-- Insert sensor readingsINSERT INTO sensor_readings (timestamp, sensor_id, temperature, humidity)VALUES (NOW(), 'sensor-001', 23.5, 65.0), (NOW(), 'sensor-002', 24.1, 62.5);Query with Time Bucket
-- Aggregate by 5-minute bucketsSELECT time_bucket('5 minutes', timestamp) AS bucket, sensor_id, AVG(temperature) AS avg_temp, MAX(temperature) AS max_tempFROM sensor_readingsWHERE timestamp > NOW() - INTERVAL '1 day'GROUP BY bucket, sensor_idORDER BY bucket DESC;Configure Retention via SQL
-- Set retention policyALTER TABLE sensor_readingsSET RETENTION POLICY '30 days';
-- Set downsamplingALTER TABLE sensor_readingsADD CONTINUOUS AGGREGATE sensor_readings_1h EVERY '1 hour' WITH (aggregation = 'avg');Next Steps
| Topic | Guide |
|---|---|
| Complete documentation | USER_GUIDE.md |
| Code examples | EXAMPLES.md |
| Performance optimization | ../timeseries/PERFORMANCE_TUNING.md |