A time series database (TSDB) is a database built for measurements that each carry a timestamp, such as sensor readings, server metrics, prices and meter values. It's designed around how that data gets used: new points are appended constantly, queries pick a time range and usually aggregate it ("average per five minutes over the last day"), and old data is compressed, summarized or deleted on a schedule. The best-known ones are InfluxDB, Prometheus and TimescaleDB.
Plenty of teams never need a separate one, though. At moderate volumes PostgreSQL with time-based partitions does the job, and what decides it is how much data you keep, for how long, and how far back your queries reach.
What makes time series data different
Three things set it apart from the rows in a typical application database.
It's written once and rarely changed. A reading taken at 10:04 is never edited; the 10:05 reading simply arrives after it. Data mostly lands in time order, and updating or deleting single rows is the exception.
It's read in ranges. Nearly every query filters on time, and most of them aggregate: the highest temperature per hour this week, 95th-percentile latency per endpoint since the last deploy, each day's closing price. Nobody asks for row 48,213,551.
It loses value with age. Yesterday's per-second readings help you debug an incident. Last year's are only useful as hourly or daily averages, so you want raw data for a short window and summaries for much longer.
Then there's volume, which grows faster than intuition suggests. Take 2,000 sensors reporting every 10 seconds. That's 200 points a second, a write rate any database can take. It's also 17.28 million rows a day and about 6.3 billion a year.
What a time series database does differently
The products differ, but the same few techniques show up in all of them.
They partition by time. Data is stored in chunks or blocks that each cover a time range (a TimescaleDB chunk covers seven days by default). A query over the last 24 hours touches one or two of them, and removing old data means dropping whole chunks, which takes moments. A DELETE over hundreds of millions of rows, by comparison, runs for a long time and leaves bloat behind.
They compress by column. Consecutive timestamps are almost evenly spaced and consecutive values change slowly, so storing the difference between neighbours and packing it into a few bits works very well. Prometheus, for example, stores an average of 1 to 2 bytes per sample. The same reading as an ordinary PostgreSQL row costs about 52 bytes before any index: a 23-byte row header padded to 24, then 24 bytes for the timestamp, an integer sensor ID and a float once alignment padding is added, plus a 4-byte pointer to the row in its page. You can check the arithmetic against the page layout documentation.
Their query languages understand time. Functions that group rows into fixed intervals (time_bucket in TimescaleDB, date_bin in InfluxDB 3's SQL), fill gaps in sparse series or compute rates of change save you from writing the same window-function SQL again and again.
And they manage the data's lifecycle. Retention policies delete data past a certain age, and continuous aggregates or downsampling jobs keep hourly and daily summaries current as new data arrives.
Do you actually need one?
Do the arithmetic before reading product pages. At the scale most companies work at, ingest is rarely the bottleneck: two hundred points a second is a load PostgreSQL handles without special tuning, especially if you insert in batches. Storage is where it hurts, along with the queries that scan months of it.
With the row size above, the 2,000-sensor example produces about 0.9 GB of table data a day in plain PostgreSQL. That's roughly 27 GB a month and 330 GB a year, before indexes, which add a good deal more. At Prometheus's 1 to 2 bytes per sample, the same day takes 17 to 35 MB. That gap, somewhere between 25 and 50 times, is most of what a time series engine buys you, and it's why retention matters more to this decision than write speed. Thirty days of raw readings in PostgreSQL is an ordinary table. Three years of them is a storage and backup project.
Our rules of thumb:
- Stay in PostgreSQL if the raw data fits comfortably on one server for its whole retention period and you need to join measurements to your customers, devices or orders. Partition by time from the start, and move to TimescaleDB later if your hosting allows it.
- Use Prometheus, or your cloud's managed equivalent, for infrastructure and application metrics that feed dashboards and alerts. Don't build monitoring on top of your application database.
- Use a dedicated engine such as InfluxDB 3 for high-frequency telemetry from many devices, when most queries look at recent data and the business tables live somewhere else anyway.
- Look at a columnar analytics database such as ClickHouse when what you really need is ad-hoc analysis over billions of timestamped events with many dimensions: clickstreams, logs, ad impressions. That's closer to data warehouse territory than to monitoring.
The main options as of October 2026
Option | What it is | Query language | Good fit | Watch out for |
|---|---|---|---|---|
PostgreSQL with partitions | The database you already run | SQL | Moderate volumes, joins with business data | No row compression; you manage partitions |
TimescaleDB | PostgreSQL extension | SQL plus time functions | Postgres teams outgrowing plain tables | Key features need the Community edition; not on RDS or Cloud SQL |
InfluxDB 3 | Standalone server, data in Parquet files | SQL, InfluxQL | High-rate device telemetry, recent-data dashboards | Core: no compaction, about 72 hours per query by default |
Prometheus | Monitoring server that scrapes targets | PromQL | Infrastructure and service metrics, alerting | Local, unreplicated storage; 15-day default retention |
QuestDB, ClickHouse, VictoriaMetrics | Standalone servers | SQL; MetricsQL for VictoriaMetrics | Fast SQL over market or sensor data; big analytical scans; long-term Prometheus storage | One more system to run, monitor and back up |
PostgreSQL on its own
Native partitioning plus two indexes covers a lot of ground. Partition by month (or by day at higher volumes), keep a B-tree index for per-sensor lookups, and add a BRIN index on the timestamp. BRIN stores only a summary, the minimum and maximum, for each range of table blocks, so it stays tiny on tables whose physical order follows time.
CREATE TABLE readings (
time timestamptz NOT NULL,
sensor_id integer NOT NULL,
value double precision NOT NULL
) PARTITION BY RANGE (time);
CREATE TABLE readings_2026_10 PARTITION OF readings
FOR VALUES FROM ('2026-10-01') TO ('2026-11-01');
CREATE TABLE readings_2026_11 PARTITION OF readings
FOR VALUES FROM ('2026-11-01') TO ('2026-12-01');
-- per-sensor lookups: WHERE sensor_id = 42 AND time > now() - interval '1 day'
CREATE INDEX ON readings (sensor_id, time DESC);
-- small index for "all sensors in this time range" scans
CREATE INDEX ON readings USING brin (time);
-- months later, when October falls out of retention.
-- CONCURRENTLY (PostgreSQL 14+) doesn't lock queries out of readings,
-- but it can't run inside a transaction block.
ALTER TABLE readings DETACH PARTITION readings_2026_10 CONCURRENTLY;
DROP TABLE readings_2026_10;Someone has to create next month's partition before it's needed, because an insert whose timestamp no partition covers fails with an error. Forget it and every insert from the first second of the new month is rejected. The pg_partman extension creates partitions ahead of time and drops old ones, and it's available on Amazon RDS and Google Cloud SQL, which matters because TimescaleDB isn't. What plain PostgreSQL won't do is compress these rows, so 52 bytes per reading stays 52 bytes.
TimescaleDB
TimescaleDB is a PostgreSQL extension. You keep SQL, joins, your drivers and your backup tooling, and you get hypertables (tables split into time chunks automatically), columnar compression, continuous aggregates and retention policies. The current release is 2.30, from September 2026, and it supports PostgreSQL 16 to 18. The company behind it renamed itself Tiger Data in 2025, and its managed service is now called Tiger Cloud. The extension kept its name.
Licensing is the catch, and it decides where you can run it. TimescaleDB comes in two editions, and the Apache 2 edition has no continuous aggregates, no columnstore and no retention policies. Those live in the Community edition under the Tiger Data License, which the big cloud providers don't offer. In practice:
- Amazon RDS and Google Cloud SQL don't offer TimescaleDB at all.
- Azure Database for PostgreSQL offers it, but Microsoft supports only the Apache-licensed build.
- Supabase has deprecated the extension for Postgres 17 projects.
- For the full feature set you self-host or use Tiger Cloud.
On your own server, add timescaledb to shared_preload_libraries in postgresql.conf and restart PostgreSQL before running CREATE EXTENSION. Here is the same table as a hypertable, with hourly summaries and retention:
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE TABLE readings (
time timestamptz NOT NULL,
sensor_id integer NOT NULL,
value double precision NOT NULL
) WITH (
tsdb.hypertable,
tsdb.segmentby = 'sensor_id',
tsdb.orderby = 'time DESC'
);
-- hourly summary per sensor, refreshed in the background
CREATE MATERIALIZED VIEW readings_hourly
WITH (timescaledb.continuous) AS
SELECT time_bucket(INTERVAL '1 hour', time) AS bucket,
sensor_id,
avg(value) AS avg_value,
min(value) AS min_value,
max(value) AS max_value
FROM readings
GROUP BY bucket, sensor_id
WITH NO DATA;
SELECT add_continuous_aggregate_policy('readings_hourly',
start_offset => INTERVAL '3 days',
end_offset => INTERVAL '1 hour',
schedule_interval => INTERVAL '30 minutes');
-- raw readings for 30 days, hourly summaries for two years
SELECT add_retention_policy('readings', drop_after => INTERVAL '30 days');
SELECT add_retention_policy('readings_hourly', drop_after => INTERVAL '2 years');On TimescaleDB 2.23 and later, that CREATE TABLE uses the first timestamp column for partitioning and adds a columnstore policy that compresses chunks once they're older than the chunk interval, seven days by default. Self-hosted versions 2.20 to 2.22 need an explicit add_columnstore_policy call. How much you save depends heavily on the data, so compare hypertable_size('readings') before and after the first chunks convert.
There's a trap when you combine the two policies. When a continuous aggregate refreshes, it recomputes its window from the raw table. If the retention policy has already dropped raw chunks inside that window, the refresh reads them as deleted and removes the matching summary rows too. Make sure the refresh window never reaches into dropped data: keep the aggregate's start_offset smaller than the raw table's drop_after, as above, where it's 3 days against 30.
InfluxDB 3
InfluxDB 3 is a ground-up rewrite. It stores data as Parquet files on local disk or in object storage (S3, Google Cloud Storage, Azure Blob Storage, MinIO), and you query it with SQL or InfluxQL. Flux, the query language of InfluxDB 2, doesn't run on version 3 and is in maintenance mode, so don't start anything new with it. If you migrate from 2.x, plan to rewrite your Flux tasks.
There are two self-hosted products: Core, which is open source, and Enterprise, which is commercial and adds compaction, high availability, read replicas and historical queries. That last item matters more than it sounds. In Core, the default query-file-limit of 432 Parquet files works out to roughly 72 hours of data per query with the default 10-minute file layout. You can raise it at the cost of memory and speed. Core suits recent-data dashboards, alerting and collection at the edge; if you need to query last quarter, budget for Enterprise or keep long-term summaries in another store.
Writing is a plain HTTP request with line protocol (table,tags fields). Leave out the timestamp and the server uses its own clock; the database is created on the first write:
curl "http://localhost:8181/api/v3/write_lp?db=sensors" \
--header "Authorization: Bearer $INFLUXDB3_AUTH_TOKEN" \
--data-raw "readings,sensor=s-0042,site=depot-3 temp=4.1,humidity=81
readings,sensor=s-0043,site=depot-3 temp=3.8,humidity=79"Querying is SQL. This gets hourly averages for the last day, and the CLI picks up the token from INFLUXDB3_AUTH_TOKEN:
influxdb3 query --database sensors \
"SELECT date_bin(INTERVAL '1 hour', time) AS bucket, sensor, avg(temp) AS avg_temp
FROM readings
WHERE time >= now() - INTERVAL '1 day'
GROUP BY 1, sensor
ORDER BY 1, sensor"On AWS, Amazon Timestream for InfluxDB runs both Core and Enterprise as a managed service.
Prometheus
Prometheus is a monitoring system with a time series database built in. It scrapes /metrics endpoints on a schedule, stores the samples locally, evaluates alert rules and answers PromQL queries for Grafana dashboards. For service and Kubernetes metrics it's the usual choice, and it's very efficient at that job. It's also where the metrics you collect for performance work tend to end up.
It isn't meant to be an archive, and the storage documentation linked earlier says so plainly: local storage isn't clustered or replicated, and it keeps 15 days of data by default. For longer retention, or for several Prometheus servers behind one query endpoint, teams send samples by remote write to Thanos, Grafana Mimir or VictoriaMetrics. The same page gives a sizing formula: retention in seconds × samples per second × bytes per sample. If the 2,000 sensors were Prometheus metrics, 15 days at 2 bytes a sample would come to about 520 MB.
Modeling: tags, values and cardinality
Every TSDB separates what identifies a series from what you measure. InfluxDB calls them tags and fields; Prometheus has labels and the sample value; in TimescaleDB they're ordinary columns, and the identifying ones go into segmentby. A series is one combination of identifiers, such as sensor=s-0042, site=depot-3.
The number of distinct series is called cardinality, and letting it run away is the most common way to hurt a TSDB. 2,000 sensors with three metrics each make 6,000 series, which is nothing. Add a label whose values never repeat (a request ID, a user ID, a full URL with its query string) and every new value starts a new series with its own index entries and memory. Keep identifiers bounded, and send unbounded values to a log or event store.
In PostgreSQL and TimescaleDB there's one more choice: narrow or wide rows. Narrow means one row per reading (time, sensor_id, metric, value) and suits sensors that report different things at different times. Wide means one row per device per timestamp, with a column per metric. It pays the row header once for several values, so it's usually the better choice when a device reports everything at once.
Time series that are personal data
Not every series comes from a machine. A vehicle's position every minute, a wearable's heart-rate readings or a household's smart-meter consumption become personal data as soon as they can be tied to a person. The GDPR's storage limitation principle (Article 5(1)(e)) says you keep such data in identifiable form for no longer than its purpose needs, so decide the retention period for each purpose and write it down.
Retention policies are how you enforce that period without relying on anyone's memory: an add_retention_policy on the raw table, or a scheduled DROP TABLE on old partitions. Two things tend to get missed. Hourly summaries per person or per device are still personal data, so give them a retention period as well, or aggregate them across enough people that they no longer point to anyone. And dropped chunks live on in your backups, so backup retention has to fit the same policy.
Getting data in, and looking at it
Devices lose connectivity and databases restart, so don't have each device write straight to the database. Buffer on the device or a gateway, send in batches (MQTT is the common protocol for this), and let a consumer write to the database. A restart then delays data instead of losing it. For the device side, see our post on edge computing. For InfluxDB, Telegraf is the usual collector, and for dashboards Grafana reads PostgreSQL, TimescaleDB, InfluxDB and Prometheus alike.
Frequently asked questions
Is Prometheus a time series database?
It contains one, but you don't use it the way you use a database. Prometheus pulls current values from your services on a schedule, and it accepts samples pushed over remote write only if you turn on the receiver with a command-line flag. There's no SQL and no updating of stored samples, and loading older data is a separate, offline step with promtool.
Is InfluxDB free?
InfluxDB 3 Core is open source under the MIT or Apache 2 license and free to run anywhere. Enterprise is commercial: there's a 30-day trial and a free at-home license for non-commercial use, and production use needs a paid license.
What happened to Amazon Timestream?
AWS closed Timestream for LiveAnalytics to new customers on 20 June 2025; existing workloads keep running. New users are pointed to Amazon Timestream for InfluxDB, which has offered InfluxDB 3 Core and Enterprise since October 2025.
Can Redis store time series?
Yes. Redis Open Source has a time series data type with per-series retention and compaction rules. It suits short, hot windows such as live counters or the last hour of readings, and memory is the limit. Our post on Redis use cases covers where it fits next to its other jobs.
If you're sizing a time series workload for your own product and want a second opinion, it's the kind of question we work on in data engineering.
Related Articles
MLOps Guide: What to Set Up First, and What Can Wait
MLOps gets a model into production and keeps it useful there. Here is the order we'd set it up in, with current MLflow and DVC examples, and what changes for LLM features.
Read More: MLOps Guide: What to Set Up First, and What Can WaitComputer Vision Applications: Where It Works and Where It Struggles
Where computer vision works today, from inspection lines to invoices and medical scans, what makes some applications hard, and when a general vision model saves you training your own.
Read More: Computer Vision Applications: Where It Works and Where It StrugglesAI Agent Development: When You Need One and How to Build It
An AI agent is a language model working in a loop with tools. When you need one, the loop in Python, choosing a framework, keeping it safe, and what each run costs.
Read More: AI Agent Development: When You Need One and How to Build It
