timescaledb
Enables scalable inserts and complex queries for time-series data
Repository
timescale/timescaledb
https://github.com/timescale/timescaledb
Source
timescaledb-2.25.2.tar.gz
timescaledb-2.25.2.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
timescaledb | 2.25.2 | TIME | Timescale | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1000 | timescaledb | No | Yes | Yes | Yes | No | No | timescaledb_information |
| Related | timescaledb_toolkit timeseries pg_cron pg_partman periods temporal_tables emaj pg_task |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.25.2 | 1817161514 | timescaledb | - |
| RPM | PIGSTY | 2.25.2 | 1817161514 | timescaledb-tsl_$v | - |
| DEB | PIGSTY | 2.25.2 | 1817161514 | postgresql-$v-timescaledb-tsl | - |
Build
You can build the RPM / DEB packages for timescaledb using pig build:
pig build pkg timescaledb # build RPM / DEB packages
Install
You can install timescaledb directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install timescaledb; # Install for current active PG version
pig ext install -y timescaledb -v 18 # PG 18
pig ext install -y timescaledb -v 17 # PG 17
pig ext install -y timescaledb -v 16 # PG 16
pig ext install -y timescaledb -v 15 # PG 15
dnf install -y timescaledb-tsl_18 # PG 18
dnf install -y timescaledb-tsl_17 # PG 17
dnf install -y timescaledb-tsl_16 # PG 16
dnf install -y timescaledb-tsl_15 # PG 15
apt install -y postgresql-18-timescaledb-tsl # PG 18
apt install -y postgresql-17-timescaledb-tsl # PG 17
apt install -y postgresql-16-timescaledb-tsl # PG 16
apt install -y postgresql-15-timescaledb-tsl # PG 15
Preload:
shared_preload_libraries = 'timescaledb';
Create Extension:
CREATE EXTENSION timescaledb;
Usage
Create a table and turn it into hypertable
DROP TABLE IF EXISTS ts_test;
CREATE TABLE ts_test
(
ts TIMESTAMPTZ NOT NULL,
id BIGINT,
v INTEGER -- payload
);
SELECT create_hypertable('ts_test', by_range('ts'));
INSERT INTO ts_test
SELECT now() + (i || ' seconds')::INTERVAL, i, i % 100
FROM generate_series(1, 1000000) i;
Continuous Agg Example:
CREATE MATERIALIZED VIEW ts_hourly
WITH (timescaledb.continuous) AS
SELECT time_bucket('1 hour', ts) AS bucket,
count(*) AS cnt,
avg(v) AS avg_v
FROM ts_test
GROUP BY bucket;
-- Add a refresh policy to keep the continuous aggregate up to date
SELECT add_continuous_aggregate_policy('ts_hourly',
start_offset => INTERVAL '3 hours',
end_offset => INTERVAL '1 hour',
schedule_interval => INTERVAL '1 hour');
Job Scheduling Example:
SELECT add_job('SELECT 1','1h', initial_start => now()::timestamptz);
Compression Example:
ALTER TABLE ts_test SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'id',
timescaledb.compress_orderby = 'ts'
);
-- Add a compression policy to compress chunks older than 1 day
SELECT add_compression_policy('ts_test', INTERVAL '1 day');
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.