Data & Architecture
Time series and analytics that stay fast
Time series grow constantly and are usually queried in time windows. With TimescaleDB, everything stays in PostgreSQL; with ClickHouse, analyses over very large datasets run column-oriented. We plan aggregates, compression and retention so that dashboards stay fast and data volumes manageable.
TimescaleDB extends PostgreSQL with time-series features; ClickHouse is a column-oriented database for fast analytics across very large datasets.
Data flow
How Time series & analytics fits into your processes
- Sensors
- Ingest
- Hypertable
- Aggregates
- Dashboard
Use cases
What we build with Time series & analytics
Measurement and sensor data
Continuously store and monitor values from equipment and devices.
Prices and rates
Capture, compare and analyze price series over time.
Dashboards
Metrics from precomputed aggregates instead of raw data.
Event analytics
Analyze usage and processes column-oriented across large datasets.
Typical projects
Why companies bring us in
- 01
Sensor data from equipment
- Starting point
- Equipment delivers readings continuously, the database gets slower and reports spanning months take too long.
- Solution
- We switch to hypertables, calculate hourly values as continuous aggregates and compress older raw data.
- Result
- Dashboards read aggregated values; raw data remains available for detailed analysis for the defined period.
- 02
Compare price series
- Starting point
- Prices from multiple sources need to be compared over long periods and shown as trends.
- Solution
- We store prices per source and point in time and aggregate them into daily and monthly values.
- Result
- Trends and comparisons are available instantly, without computing every query across all raw data.
- 03
Analysis of very large datasets
- Starting point
- Event data grows so much that analytics in the application database disrupt operations.
- Solution
- We consolidate the events in ClickHouse and sort tables by the most common filters.
- Result
- Analytics run separately from daily operations and no longer slow down the application.
From practice
Time series & analytics in our projects
- Readings from ten measuring devices in a research lab are stored in a time series database (InfluxDB) and analyzed in dashboards.
Approach
How we introduce Time series & analytics
- 1
Clarify queries
Which time windows, resolutions and metrics are needed?
- 2
Storage model
Define hypertables or MergeTree tables, partitions and sort keys.
- 3
Aggregates and downsampling
Precompute hourly and daily values, compress raw data.
- 4
Retention and operations
Set retention periods per resolution, set up backups and monitoring.
Result
What you get from us
- Storage model with partitions and sort keys
- Ingest pipeline for measurements or events
- Precomputed aggregates per resolution
- Compression and retention rules
- Queries and interface for dashboards
- Backups and monitoring of data volume
create table messwerte (
zeit timestamptz not null,
sensor_id integer not null,
wert double precision
);
select create_hypertable('messwerte', 'zeit');
create materialized view messwerte_stunde with (timescaledb.continuous) as
select time_bucket('1 hour', zeit) as stunde, sensor_id, avg(wert) as mittel
from messwerte group by stunde, sensor_id;
select add_continuous_aggregate_policy('messwerte_stunde',
start_offset => interval '3 days', end_offset => interval '1 hour',
schedule_interval => interval '1 hour');
select add_retention_policy('messwerte', interval '90 days');
Quality
What we watch for with Time series & analytics
- 1
Time zones
We store timestamps as timestamptz and deliberately calculate daily values in the correct time zone.
- 2
Late-arriving values
Readings sometimes arrive late, and aggregates must recalculate those time ranges.
- 3
Sort key
In ClickHouse, sort order determines speed, so we choose it based on the filters.
- 4
Retention per resolution
Raw data, hourly and daily values get their own retention periods, matched to needs and data protection.
- 5
No individual rows
Column-oriented databases like batches, so we write in bulk instead of row by row.
Comparison
TimescaleDB or ClickHouse?
TimescaleDB
- Foundation
- Extension for PostgreSQL
- Queries
- Full SQL with joins to business data
- Writing
- Single rows and batches
- Changes
- Update and delete as usual
- Operations
- In the existing database
ClickHouse
- Foundation
- Dedicated column-oriented database
- Queries
- SQL dialect, strong at aggregations
- Writing
- Best in larger batches
- Changes
- Possible, but not the norm
- Operations
- Additional service
TimescaleDB fits when time series are closely tied to business data. ClickHouse fits pure analytics across very large datasets.
Related
Often combined with
Time series & analytics
Common questions
Tap a question.
