Built for data stamped with time: metrics, sensors and logs (InfluxDB, TimescaleDB).
A time series database (TSDB) is built for data where every row has a timestamp: CPU use every 10 seconds, the temperature from a sensor, the price of a stock, a log line.
Think of a series as one line on a graph over time, such as "CPU of server A". A TSDB stores millions of these lines. Each point has a timestamp, a value (a number you measure) and tags (labels such as host=a, region=eu that say which line it belongs to).
You can store this in a normal SQL table, and for small data that is fine. At large scale the pattern is special: huge write volume, data that is never updated, and queries that always cut by time. A TSDB uses this pattern. It groups data by time, compresses neighbouring values (they are usually close to each other), and drops old data cheaply by removing a whole time chunk at once.
| Idea | What it does | Example |
|---|---|---|
| Time partitioning (chunks) | Splits data into pieces by time range, so queries and deletes touch only some chunks. | TimescaleDB hypertables, InfluxDB shards |
| Time bucket | Groups points into fixed windows and gives one value per window. | time_bucket('5 minutes', ts), GROUP BY time(5m) |
| Downsampling / rollup | Stores a smaller summary (avg, min, max, count) of old data. | Continuous aggregates, Flux tasks |
| Retention policy | Deletes data older than a set age. | Keep raw 7 days, keep hourly 1 year |
| Compression | Stores the difference between neighbours instead of full values. | Delta-of-delta timestamps, Gorilla-style floats |
| Cardinality | How many different series exist (the number of tag combinations). | 1000 hosts x 50 metrics = 50,000 series |
SELECT time_bucket('5 minutes', ts) AS bucket,
host,
avg(cpu) AS avg_cpu,
max(cpu) AS max_cpu
FROM metrics
WHERE ts > now() - interval '6 hours'
GROUP BY bucket, host
ORDER BY bucket;A simplified model: one series, one reading every 10 seconds, fixed data made by maths (no random numbers). Real systems also compress points (for example delta-of-delta on timestamps), so real storage is much smaller than this point count suggests.
| Term | Meaning in easy words |
|---|---|
| Time series | A list of values measured over time, one after another |
| Point / sample | One measurement with a timestamp |
| Series | All points that share the same metric name and tags |
| Tag / label | An indexed key=value that says which series a point belongs to |
| Field / value | The measured number (or numbers) in a point |
| Cardinality | The number of different series |
| Downsampling | Replacing many points with fewer summary points |
| Retention policy | A rule that deletes data after a set age |
| Time bucket | A fixed time window, such as 5 minutes, used for grouping |
| Hypertable / chunk | A table that is silently split into time-range pieces |
| Choice | We gain | We lose |
|---|---|---|
| Keep raw data longer | Full detail for investigations | More storage and slower old queries |
| Bigger rollup buckets | Much less storage | Short spikes are hidden (use max as well as avg) |
| More tags | More ways to filter and group | More series, more memory |
| Purpose-built TSDB | Best speed and size for metrics | Poor general-purpose querying |
| TSDB on SQL | One system, full SQL | Less extreme write scale |