TimescaleDB

On this page 7

TimescaleDB is an open-source extension to PostgreSQL that adds storage, indexing and query features designed for time-series data, such as sensor readings, financial ticks, application metrics and event logs. Among modern database systems, it occupies a distinctive position: instead of building a new engine, it keeps full SQL, PostgreSQL transactions and the PostgreSQL ecosystem while automatically partitioning data by time behind a single logical table.

The extension is developed by the company formerly known as Timescale (renamed TigerData in 2025) and is offered both as a self-hosted package and as a managed cloud service. Its central abstraction, the hypertable, lets engineers write ordinary INSERT and SELECT statements while the extension handles chunking, compression, retention and incremental aggregation in the background.

How hypertables and chunks organize time-series data

A hypertable is a virtual table that TimescaleDB splits into many ordinary PostgreSQL tables called chunks, each covering a fixed time interval. An administrator creates a regular table and then converts it with create_hypertable, naming the time column that drives partitioning. From that point, every insert is routed to the chunk whose time range matches the row.

Chunking matters because time-series workloads are dominated by recent writes and range queries. Small, recent chunks keep their indexes in memory, so inserts avoid the random disk access that slows a single giant B-tree. During queries, the planner applies chunk exclusion: it skips every chunk whose time range cannot satisfy the WHERE clause, which reduces scans to a fraction of the data. Optional space partitioning on a second column, such as a device identifier, can further divide each time slice.

The following table summarizes the main building blocks and what each controls.

ComponentWhat it doesTypical setting
HypertablePresents many chunks as one SQL tableOne per measurement stream
ChunkStores rows for one time intervalDefault interval of 7 days
Chunk intervalSets the time span of each chunkSized so active chunks fit in memory
Continuous aggregateKeeps a materialized rollup up to dateHourly or daily buckets
Compression policyConverts older chunks to columnar formChunks older than days or weeks
Retention policyDrops chunks past a cutoff ageMonths to years, per regulation
Core TimescaleDB components

Compression, continuous aggregates and retention

TimescaleDB adds three automated mechanisms that address the lifecycle of time-series data: storage cost grows quickly, while query interest shifts from raw points to summaries. A built-in job scheduler runs these policies in the background, so administrators rarely need external cron jobs.

  • Native compression rewrites older chunks into a columnar format, grouping values by a segmentby column and ordering them by an orderby column. Similar adjacent values compress well with delta, delta-of-delta and dictionary encodings, and storage reductions of 90 percent or more are common for regular metrics, although results depend heavily on data shape.
  • Continuous aggregates are materialized views over the time_bucket function that refresh incrementally, recomputing only buckets touched by new or changed data. A real-time aggregation option can union materialized results with not-yet-materialized raw rows.
  • Retention policies remove whole chunks with drop_chunks, which is far cheaper than a large DELETE because it avoids row-by-row deletion, table bloat and heavy vacuum work.

Recent releases describe the hybrid row and column storage as Hypercore, in which recent data stays in the row-oriented rowstore for fast writes and updates, while older data moves to the columnstore for analytical scans. Updates to compressed data are supported but cost more than updates to uncompressed chunks, so late-arriving data should be considered when choosing the compression age.

TimescaleDB compared with other time-series and analytical databases

TimescaleDB competes mainly with purpose-built time-series engines and columnar analytical databases. Its distinguishing advantage is that it remains PostgreSQL, so relational joins, foreign keys, extensions such as PostGIS and standard drivers all keep working. The comparison below highlights the practical differences.

SystemStorage modelQuery languageBest fit
TimescaleDBPostgreSQL rows plus columnar chunksFull SQLTime series joined with relational data
PostgreSQLHeap tables with optional partitioningFull SQLGeneral transactional workloads
InfluxDBPurpose-built time-series engineSQL and InfluxQL, depending on versionMetrics with simple tag models
ClickHouseColumnar MergeTree tablesSQL dialectVery large analytical scans
Apache CassandraWide-column, log-structuredCQLMassive write volume across regions
How TimescaleDB differs from related systems

The trade-off is that a single-node PostgreSQL foundation sets the scaling ceiling. TimescaleDB once offered a multi-node mode, but it was deprecated and removed, and horizontal scale now relies on read replicas, tiered storage in the managed service or application-level sharding. Workloads that need petabyte-scale ad hoc analytics often favor a dedicated columnar engine.

Designing and tuning a TimescaleDB deployment

Good performance depends on a few design decisions made at table creation, because changing them later requires migration or new chunks. The most influential choice is the chunk interval: a commonly cited guideline is that the chunks currently receiving writes, together with their indexes, should fit within roughly 25 percent of available memory.

SituationRecommended choiceReason
Very high ingest rateShorter chunk interval, such as 1 day or lessKeeps active indexes in memory
Sparse, slow dataLonger interval, such as 30 daysAvoids thousands of tiny chunks
Queries filtered by deviceUse the device column as segmentbyImproves compression and pruning
Dashboards over long rangesBuild continuous aggregatesAvoids rescanning raw points
Frequent late correctionsDelay compression by several daysReduces costly compressed updates
Decision guide for common configuration choices

Indexes should follow query patterns, typically a composite index on the identifier and time in descending order. Batching inserts into multi-row statements or using COPY raises ingest throughput considerably compared with single-row inserts. Monitoring the number of chunks per hypertable also helps, since planning time grows when queries cannot exclude chunks.

Limitations, licensing and common mistakes

TimescaleDB inherits both the strengths and the constraints of PostgreSQL, including MVCC overhead, vacuum maintenance and a write path that is heavier than log-structured engines. Teams also need to understand licensing: the core is Apache 2.0, while features such as compression and continuous aggregates are published under the Timescale License, which permits internal use but restricts offering the database itself as a hosted service.

SymptomLikely causeFix
Slow queries over recent dataChunk interval too large for memoryReduce the interval for new chunks
High planning timeToo many small chunksIncrease the interval or merge chunks
Poor compression ratioUnsuitable segmentby columnSegment by a moderately repeating key
Disk usage keeps growingNo retention policy definedAdd add_retention_policy with a cutoff
Stale dashboard numbersAggregate refresh window too narrowWiden the refresh policy offsets
Frequent problems and how to correct them

A frequent misconception is that TimescaleDB is a separate database server. It is an extension loaded into PostgreSQL, so version compatibility between the extension and the PostgreSQL major release must be checked during every upgrade, and managed PostgreSQL providers may not offer the licensed feature set.

In plain words

TimescaleDB is an add-on that makes the popular PostgreSQL database much better at handling data stamped with a time, such as temperature readings every second or website traffic every minute.

Think of a huge notebook of measurements. Instead of writing everything in one endless book, TimescaleDB files each week into its own folder. Finding last Tuesday means opening one folder, not leafing through years of pages. Old folders get squeezed to a fraction of their size, and folders past a chosen age can be thrown away automatically.

The key point is that people still use ordinary SQL to ask questions, so existing tools and skills keep working.

A real-world example

A regional water utility monitors 4,000 pressure and flow sensors that each report every 10 seconds, producing roughly 35 million rows per day. Engineers store the readings in a TimescaleDB hypertable with a one-day chunk interval, keyed by sensor identifier and timestamp, alongside ordinary PostgreSQL tables describing pipes, districts and maintenance history.

A compression policy converts chunks older than seven days to columnar form, segmented by sensor, which shrinks historical storage by about an order of magnitude. Continuous aggregates produce hourly and daily averages for operator dashboards, and a retention policy drops raw readings after two years while the aggregates are kept indefinitely.

Because pipe metadata lives in the same database, analysts can join pressure drops directly with district maps in one SQL query. The outcome is leak detection queries that return in seconds instead of minutes, without operating a separate time-series platform.