What is a time series?
Wikipedia defines a time series as, “A series of data points indexed (or listed or graphed) in time order. Most commonly, a time series is a sequence taken at successive equally spaced points in time.”
Examples of time series?
- The temperature of a home during a day
- Position of a satellite during a day
The data in these examples constitute a monitored value (e.g. temperature or position) corresponding to the time at which the reading of the value took place.
What is TimescaleDB?
TimescaleDB is an open-source database designed to make SQL scalable for time series data. TimescaleDB is packaged as a PostgreSQL extension and released under the Apache 2 open-source license.
How to use TimescaleDB in Aiven for PostgreSQL
- Connect to the Aiven for PostgreSQL (Master) instance with PostgreSQL version 10.3 or later
Using your favorite PostgreSQL client (e.g., psql, DBeaver, PSequel, etc) connect to Aiven PostgreSQL instance
2. Create the TimescaleDB extension
CREATE EXTENSION timescaledb CASCADE;
3. Create a time series table to store time series data
CREATE TABLE location_condition (
time TIMESTAMPTZ NOT NULL,
location TEXT NOT NULL,
temperature DOUBLE PRECISION NULL,
humidity DOUBLE PRECISION NULL
4. Ingest time series data into TimescaleDB in Aiven for PostgreSQL
INSERT INTO location_condition(time, location, temperature, humidity) VALUES (NOW(), 'office', 70.0, 50.0);
Got here by accident? Learn how Aiven simplifies Postgres: