Scrivio Interview library
ConceptFoundations8 min read · updated 12 November 2026

What makes a time-series database (for example TimescaleDB, InfluxDB or a PostgreSQL time-partitioned table) different from storing metrics in a normal table? Name three features you would expect.

A time-series database is built for data that arrives in time order, is almost never updated, and is read as ranges and aggregates over time. Three features we should expect are automatic time partitioning (chunks or hypertables) so indexes stay small and old data can be dropped as whole partitions, compression of older data, often in a columnar layout, and built-in retention and downsampling such as continuous aggregates. We should also expect it to warn us about high cardinality, because too many distinct tag combinations hurts most time-series engines.

Why this question is asked

Almost every system we run produces metrics: request latency, CPU, queue depth, sensor readings. The first version usually goes into an ordinary table with a timestamp column, and it works fine for a few weeks. Then the table reaches a few billion rows, the index on the timestamp no longer fits in memory, the nightly DELETE of old rows runs for hours, and a dashboard over the last month takes a minute to load. Interviewers ask this question to see whether we understand why time-shaped data needs different storage, not just a different product name. In this answer, we will recap what makes time-series data special, see what goes wrong in a normal table, and then walk through the three features we expect from a time-series database: time partitioning, compression, and retention with downsampling. We will finish with the cardinality trap that catches many teams.

1A Quick Recap of Time-Series Data

Time-series data is a stream of measurements, each with a timestamp, a value, and a few labels that say what was measured. A label, also called a tag or a dimension, is something like host = 'web-3' or region = 'eu-west'. The combination of a metric name and one set of label values is called a series. So cpu_usage for host web-3 is one series, and cpu_usage for host web-4 is another.

Three properties make this data different from business data such as orders or users. First, it is append-mostly: we insert new readings all the time and almost never update old ones. Second, it arrives roughly in time order, so new rows are nearly always the newest. Third, the queries are about time ranges and aggregates: the average latency per minute over the last hour, or the maximum temperature per day over the last year. We rarely ask for one single row by id.

A general-purpose table does not know any of this. It treats every row as equally likely to be updated, deleted or read on its own, and it pays for that flexibility with costs that grow with the total size of the table.

2What Goes Wrong in a Normal Table

Here is the usual starting point in PostgreSQL. It is a correct design, and it is where the pain begins.

SQL
CREATE TABLE metrics (
ts timestamptz NOT NULL,
host text NOT NULL,
name text NOT NULL,
value double precision
);
CREATE INDEX ON metrics (name, host, ts);
-- after a year at 5,000 rows per second
SELECT count(*) FROM metrics; -- about 157,000,000,000
DELETE FROM metrics WHERE ts < now() - interval '90 days';
-- hours of work, huge WAL volume, and dead rows left for VACUUM

Notice what each problem comes from. The index covers the whole history, so every insert updates a B-tree that keeps growing, and once that tree is larger than memory, inserts and reads hit the disk. Removing old data with DELETE touches every expired row one by one, writes each change to the write-ahead log, and leaves dead rows that VACUUM must clean up later. And a query over a year scans billions of rows stored row by row, even though it only needs the value column.

3Feature 1: Time Partitioning With Chunks or Hypertables

The first feature is that the table is split by time into many smaller physical pieces. TimescaleDB calls the logical table a hypertable and each piece a chunk; InfluxDB uses shards organised by time; in plain PostgreSQL we create a partitioned table with one partition per day or week. When we insert a row, the database puts it into the chunk for its time range.

SQL
-- TimescaleDB: turn the table into a hypertable with one chunk per day
SELECT create_hypertable('metrics', by_range('ts', INTERVAL '1 day'));
-- A query for the last hour only touches today's chunk
EXPLAIN SELECT avg(value) FROM metrics
WHERE name = 'latency' AND ts > now() - interval '1 hour';
-- scans 1 chunk out of 365
-- Plain PostgreSQL gets the same shape with declarative partitioning
CREATE TABLE metrics_p (ts timestamptz NOT NULL, host text, name text, value float8)
PARTITION BY RANGE (ts);
CREATE TABLE metrics_2026_11_06 PARTITION OF metrics_p
FOR VALUES FROM ('2026-11-06') TO ('2026-11-07');

This gives us three wins. Each chunk has its own small index, so the index for today's chunk fits in memory and inserts stay fast no matter how much history exists. And a query with a time filter skips every chunk outside its range, which is called chunk exclusion or partition pruning. The third win comes when data expires: we drop a whole chunk, which is a quick metadata change instead of a DELETE of millions of rows. Check your TimescaleDB version for the exact create_hypertable signature, since the older form took the column name as a plain argument.

4Feature 2: Compression of Older Data

The second feature is compression. Readings that are a few days old will never change, so the database can rewrite them in a compact form. TimescaleDB groups rows of an older chunk by a segment column, such as host, and stores each column as a compressed array. Timestamps that rise by 10 seconds each time compress extremely well with delta encoding, and values that change slowly compress well too.

Because the data is stored column by column, a query that averages one column reads only that column. That is the same idea as a columnar analytics database, applied to the cold part of the table.

SQL
ALTER TABLE metrics SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'name, host',
timescaledb.compress_orderby = 'ts DESC'
);
SELECT add_compression_policy('metrics', INTERVAL '7 days');
-- chunks older than 7 days are compressed in the background
-- typical result: 10x to 20x less disk for those chunks

Recent TimescaleDB versions describe this as the columnstore and have newer function names for the same policy, so check your version. The idea does not change: hot recent data stays in row form for fast inserts, and older data becomes columnar and small.

5Feature 3: Retention Policies and Downsampling

The third feature is managing data over its lifetime. Nobody needs per-second CPU readings from two years ago, but they may need hourly averages from that time. A time-series database lets us declare both rules: keep raw data for a short period, and keep pre-computed summaries for a long one. TimescaleDB calls the summaries continuous aggregates, which are materialised views that refresh incrementally, only recomputing the time buckets that received new data.

SQL
CREATE MATERIALIZED VIEW metrics_hourly WITH (timescaledb.continuous) AS
SELECT time_bucket('1 hour', ts) AS bucket, name, host,
avg(value) AS avg_value, max(value) AS max_value
FROM metrics
GROUP BY bucket, name, host;
SELECT add_continuous_aggregate_policy('metrics_hourly',
start_offset => INTERVAL '3 hours', end_offset => INTERVAL '1 hour',
schedule_interval => INTERVAL '1 hour');
SELECT add_retention_policy('metrics', INTERVAL '30 days');
-- raw chunks older than 30 days are dropped; hourly rows stay
Plain table versus time-series storage
ConcernNormal tableTime-series database
Index sizeOne index over all historySmall index per time chunk
Query for last hourIndex scan over a huge treeTouches only the newest chunk
Removing old dataDELETE row by row, then VACUUMDrop whole chunks instantly
Old data on diskRow format, uncompressedColumnar and compressed, often 10x smaller
Long-range dashboardsAggregate raw rows every timeRead pre-computed hourly or daily rows
Each time-series feature removes a cost that grows with total table size.

So a dashboard over the last year reads about 8,760 hourly rows per series instead of about 3 million raw readings at 10-second resolution, and the raw table never grows beyond 30 days. In plain PostgreSQL we would need a scheduled job that fills a summary table and drops old partitions.

6The Catch: High Cardinality

There is one warning we should give in the interview. Many time-series engines keep an in-memory index of every series, and some store each series separately. If we add a label with many possible values, such as user_id or request_id, the number of series explodes. Ten thousand hosts is fine; ten million users times fifty endpoints is not. Memory use, index size and query time all grow with the number of series, not just the number of points.

So a good design keeps labels bounded: host, region, endpoint and status code are fine, while unbounded identifiers belong in logs or traces. TimescaleDB, being PostgreSQL underneath, suffers less from this than engines built around a series index, but a segment column with millions of distinct values still makes compression much less effective.

7Follow-up questions

Can I get these features without a separate database?

Yes, to a large extent. PostgreSQL declarative partitioning gives time partitions and cheap drops, a scheduled job can maintain summary tables, and tools like pg_partman automate creating and removing partitions. What we do not get out of the box is transparent columnar compression and incremental continuous aggregates, which is where an extension like TimescaleDB earns its place.

Why not just put metrics in a columnar warehouse?

A warehouse is excellent for large historical scans but usually weaker at a steady stream of small inserts and at sub-second dashboards over the last few minutes. Many systems use both: a time-series store for recent and summarised data, and object storage or a warehouse for multi-year analytics.

8Conclusion

In this answer, we saw that time-series data is append-mostly, time ordered and read as ranges and aggregates, and that a normal table pays for flexibility it does not need. A time-series database partitions by time so indexes stay small and old data is dropped by whole chunks, compresses older data into a columnar form, and manages data over its life with retention policies and continuous aggregates. We also saw that unbounded labels create high cardinality, which is the most common way to hurt a time-series engine.

What to say in the interviewAbout 80 seconds aloud

Open with

Metrics data has a very particular shape: it is appended in time order, almost never updated, and queried by time range with aggregates like average per minute. A normal table treats it like any other data, so one index covers all history and keeps growing, deleting old rows means a huge DELETE and VACUUM, and long-range queries scan raw rows.

Then, if they want more

A time-series database, whether that is TimescaleDB, InfluxDB or a well-partitioned PostgreSQL table, fixes those costs. The three features I would expect are, first, automatic time partitioning into chunks, so each chunk has a small index, queries skip chunks outside their time range, and retention is just dropping old chunks.

Second, compression of older chunks, usually columnar with delta encoding on timestamps, which typically saves ten times or more on disk and makes scans of one column cheap. Third, lifecycle features: retention policies plus continuous aggregates or downsampling, so a yearly dashboard reads hourly rows instead of billions of raw points. The one thing I would warn about is cardinality.

Every distinct combination of label values is a series, so putting something like user id in a label multiplies the series count and hurts memory and query speed. I keep labels bounded and put identifiers in logs or traces.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation, MongoDB manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What makes a time-series database (for example TimescaleDB, InfluxDB or a PostgreSQL...": https://scrivio-interview-library.netlify.app/databases/nosql-fundamentals/f6c5eccac0/