• Start

Time-series

Time-series model

Learn how time-series workloads centre on timestamps, tags, and aggregations in SurrealDB, and where to find guides on bucketing, IoT-style modelling, and metrics.

A time series database is optimised for storing, querying, and managing time-stamped data. Rather than treating the timestamp as just another attribute, TSDBs place time at the forefront of data modelling, indexing, retention, and query optimisation. The queries in time series workloads often include:

  • Finding or aggregating values over time windows (e.g., last 5 minutes, last 30 days).

  • Detecting patterns or anomalies (peaks, troughs, rolling averages).

  • Combining real-time and historical data for a holistic view of a system’s behaviour.

This section helps you understand how to think like a time series database user, and how SurrealDB can accommodate these needs.

  • Timestamp: Every record includes at least one timestamp field, typically indicating when the data was created, measured, or observed.

  • Measurement / metrics: Time series data often revolves around measurements, like temperature, CPU usage, or stock prices. Each measurement can have multiple fields or tags.

  • Tags (or labels): Extra dimensions that categorise data. For instance, a sensor reading might have a location or a device_id tag. These tags help you filter or group data.

  • Aggregations: Because time series data can be massive (think thousands of data points per second), it is common to store or generate aggregated values (e.g., hourly averages or daily sums) for faster analytics.

  • Retention policies: Time series datasets can grow exponentially. Many TSDBs support retention policies that drop or downsample older data while keeping recent data at high granularity.

  • Time buckets: It is typical to group data into buckets (e.g., 1-minute, 5-minute, or 1-day intervals) for analytics.

  • Efficient ingestion: TSDBs are optimised for high write throughput, as time series data often arrives in large bursts or continuous streams.

  • Fast time-based queries: Data structures are specialised for retrieving data over specific time windows or intervals.

  • Built-in aggregation and downsampling: Many TSDBs offer native functions to summarise data by minute, hour, or other intervals.

  • Scalability: Time partitioning or sharding strategies make it easier to handle large volumes of time series data.

  • Retention control: You can automatically expire older data or keep only aggregated versions to save storage.

Was this page helpful?