0PricingLogin
SQL Academy · Lesson

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

  1. TimescaleDB Hypertables
  2. Continuous Aggregates
  3. Compression and Retention Policies
  4. Time-Series Index Choices
← Back to SQL Academy