Skip to content

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:

  1. Create a time-series table
  2. Write time-series data points
  3. Query time ranges
  4. Configure retention policies
  5. Set up downsampling

Using SQL Interface

HeliosDB supports time-series operations through SQL:

Create Time-Series Table

-- Create a time-series optimized table
CREATE 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 readings
INSERT 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 buckets
SELECT
time_bucket('5 minutes', timestamp) AS bucket,
sensor_id,
AVG(temperature) AS avg_temp,
MAX(temperature) AS max_temp
FROM sensor_readings
WHERE timestamp > NOW() - INTERVAL '1 day'
GROUP BY bucket, sensor_id
ORDER BY bucket DESC;

Configure Retention via SQL

-- Set retention policy
ALTER TABLE sensor_readings
SET RETENTION POLICY '30 days';
-- Set downsampling
ALTER TABLE sensor_readings
ADD CONTINUOUS AGGREGATE sensor_readings_1h
EVERY '1 hour'
WITH (aggregation = 'avg');

Next Steps

TopicGuide
Complete documentationUSER_GUIDE.md
Code examplesEXAMPLES.md
Performance optimization../timeseries/PERFORMANCE_TUNING.md

See Also: README.md | User Guide | Examples