TimescaleDB Hypertables
Convert a Postgres table into a TimescaleDB hypertable, with automatic time partitioning by chunk interval.
What Is TimescaleDB?
A PostgreSQL extension built for time-series data. Adds automatic time-partitioning, compression, retention, and continuous aggregates. Used standalone or alongside regular Postgres.
Hypertable
A logically single table that's physically split into "chunks" by time:
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE TABLE metrics (
ts TIMESTAMPTZ NOT NULL,
device_id BIGINT NOT NULL,
value DOUBLE PRECISION
);
SELECT create_hypertable('metrics', 'ts');
-- metrics is now a hypertable, chunks created automatically.All lessons in this course
- TimescaleDB Hypertables
- Continuous Aggregates
- Compression and Retention Policies
- Time-Series Index Choices