FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Tools

Under 100m sensor rows, plain Postgres partitioning is enough

The vendor measured its own drop from 67 seconds to 1.8ms; at the plant, an FDE has to decide on row counts, dashboard resolution and the client's cloud.

ShareLinkedInFacebookX

In brief

  • A benchmark by author Gabriel Anhaia (not independently verified) found native partitioning is enough below 100 million rows; in his view, TimescaleDB's real strength is continuous aggregates.
  • Compression, continuous aggregates and retention policies exist only in the Community Edition (TSL license), while Azure Database for PostgreSQL flexible server offers only the Apache-2 edition.
  • The raw-data retention interval must be longer than the aggregate's refresh window, or aggregated data may be deleted along with it.
Three-step decision tree. If the table has fewer than 100m rows, plain Postgres is enough. If not, ask whether the dashboard aggregates across many days: if it does not, use Postgres partitioning. If it does, ask whether the environment offers Community Edition: if so, install TimescaleDB; if not, use partitioning and build the aggregations yourself.
In the order the article suggests: rows per day, dashboard resolution, then the TimescaleDB edition available in the customer's environment.

An hourly-average query over one week fell from more than 67 seconds to 1.8 ms. That is the result Tiger Data, the company formerly called Timescale, published on its blog for a factory scenario: 50 rotating machines sending vibration data at 10 samples per second, running continuously for six months.

The test used an 8 CPU / 32 GiB instance, and the vendor ran it itself. It is not an independent benchmark.

The number looks good, but it does not answer the question an FDE actually faces at a plant. The client already runs PostgreSQL, the operations team knows it, and they want to know whether they need to install anything else.

Getting it wrong is expensive in either direction. Install an extension you do not need and there is one more thing to operate; skip it when you do need it and a few months later the dashboard takes more than ten seconds to load.

What does TimescaleDB do that plain Postgres does not?

TimescaleDB is a PostgreSQL extension. According to a blog post by Ajay Kulkarni and Mike Freedman, Timescale launched around 2017 with the aim of bringing time-series data into Postgres.

Plain Postgres is no slouch with time data. It has native partitioning, and the PostgreSQL documentation advises partitioning only when a table is genuinely large, with the rule of thumb being a table that exceeds the server’s physical memory.

It also has BRIN indexes, designed for very large tables whose columns correlate naturally with their physical location on disk, such as the timestamp column of sensor data written in sequence.

Gabriel Anhaia, an independent author, benchmarked 1 billion rows across 500 series on Postgres 18. He concluded that below 100 million rows native partitioning is enough, and at that size BRIN is not even needed yet.

Yet he also argues that continuous aggregates are where plain Postgres cannot keep up: in his test, a 90-day dashboard query took 14.2 seconds natively but only 38 ms with a continuous aggregate.

These are one person’s measurements and have not been independently verified. Even so, they tell you where to measure first: aggregate queries that span many days.

Running the numbers for a 50-machine plant

Take Tiger Data’s own scenario. Fifty machines at 10 samples per second is 500 rows per second; multiplied by 86,400 seconds, that is 43.2 million rows per day. Over six months, or 180 days, the table holds about 7.8 billion rows, and Anhaia’s 100-million-row mark is crossed after just over two days.

That arithmetic gives you the first answer. A line of 5 machines sampling once a minute would take years to reach 100 million rows, so by Anhaia’s threshold plain Postgres is enough, perhaps without partitioning at all.

High-frequency vibration data, by contrast, quickly outgrows the server’s RAM. Then the second question decides the matter: if the client wants “a chart of hourly averages over the last 90 days”, every dashboard load has to scan billions of rows.

That is when a continuous aggregate earns its keep.

A minimal setup, and the retention trap

The usual setup has three parts: a raw table, an hourly aggregate and a policy that deletes old raw data.

CREATE TABLE vibration (
  time       timestamptz NOT NULL,
  machine_id int         NOT NULL,
  value      double precision
);
SELECT create_hypertable('vibration', 'time');

CREATE MATERIALIZED VIEW vibration_hourly
WITH (timescaledb.continuous) AS
SELECT time_bucket('1 hour', time) AS bucket, machine_id, avg(value) AS avg_value
FROM vibration
GROUP BY bucket, machine_id;

SELECT add_continuous_aggregate_policy('vibration_hourly',
  start_offset => INTERVAL '7 days', end_offset => INTERVAL '1 hour',
  schedule_interval => INTERVAL '1 hour');

-- Keep raw data for 30 days: longer than the 7-day refresh window
SELECT add_retention_policy('vibration', INTERVAL '30 days');

The last line is the easiest to get wrong. Tiger Data’s documentation warns that the raw-data retention interval must be longer than the continuous aggregate’s refresh window.

Set retention to 3 days while the refresh looks back 7 days, and the first refresh after the raw data is dropped may also delete the hours already aggregated for days 4 through 7.

The client will only notice when last week’s chart suddenly shows a gap.

Can the client’s infrastructure run the full edition?

TimescaleDB comes in two editions: the Apache 2 Edition and the Community Edition under the TSL license. According to the vendor’s comparison page, compression/columnstore, continuous aggregates and retention policies are available only in the Community Edition. The hourly aggregate and add_retention_policy in the setup above therefore will not run on the Apache edition.

That has immediate consequences for the architecture. Azure Database for PostgreSQL flexible server offers only the Apache-2 edition, so if the client runs on that service, the main feature you planned to use will not be there.

The TSL license permits internal use but forbids using the software to provide a database-as-a-service. If your company’s product packages a database shared by many customers, have legal review that clause before you write the first line of SQL.

The sensible order for the first working session is therefore: calculate rows per day, ask the client what resolution the dashboard needs and over what time span, then ask where they run Postgres and which TimescaleDB edition that environment offers. Only after those three questions should you choose between native partitioning and TimescaleDB.

On a CV, a line such as “evaluated native Postgres and TimescaleDB for 43 million rows/day of sensor data, cutting dashboard load time from X to Y” shows a hiring manager that you measure before you pick a tool, a skill every FDE needs.

Tiger Data’s 67 seconds and Anhaia’s 14.2 seconds were both measured on someone else’s machines. The most reliable number is the multiplication you do yourself from your own client’s machine count and sampling rate.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
10 sources
Read next on the roadmap · Stage 3: Applied AIDeloitte asks FDEs for Strands Agents. AWS's own FDE posting doesn'tThe open-source SDK is a useful way into agent work on AWS, but it pays off only alongside the evals and RAG skills both postings want.