---
title: "Time Series Overview"
description: "Store and query sequential time-stamped data in RavenDB with built-in time series support for IoT metrics, stock prices, and event tracking."
url: "https://docs.ravendb.net/7.2/document-extensions/timeseries/overview"
version: "7.2"
---

# Time Series Overview

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

## Time Series Overview

> **Note**
>
> - A huge number of systems, including an expanding variety of IoT devices,
>   produce continuous streams of values that can be collected and used for
>   various needs. **Time series** are vectors of data points that are designated
>   to collect values over time, store them consecutively, and manage them
>   with high efficiency and performance.
>
> - RavenDB Time series can be managed and utilized using a thorough set of
>   [API methods](https://docs.ravendb.net/7.2/document-extensions/timeseries/client-api/overview.md),
>   [Studio](https://docs.ravendb.net/7.2/studio/database/document-extensions/time-series.md),
>   and [various RavenDB features](https://docs.ravendb.net/7.2/document-extensions/timeseries/time-series-and-other-features.md).
>
> - Time series data is **compressed** to lower storage usage and transaction time.
>
> - In this page:
>   - [Overview](#overview)
>     - [RavenDB's Time Series Implementation](#ravendbs-time-series-implementation)
>     - [Distributed Time Series](#distributed-time-series)
>     - [Time Series as Document Extensions](#time-series-as-document-extensions)
>     - [Time Series Features](#time-series-features)
>   - [Time Series Data](#time-series-data)
>   - [Separate Name and Data Storage](#separate-name-and-data-storage)
>   - [Time Series Segments](#time-series-segments)
>     - [Transactions Performance](#transactions-performance)
>     - [Common-Queries Performance](#common-queries-performance)
>   - [Time Series Entries](#time-series-entries)
>     - [Timestamps](#timestamps)
>     - [Values](#values)
>     - [Tags](#tags)

## Overview

Time series can be **aggregated** and **queried** to illustrate process
behavior, predict future developments, track noticeable value changes,
and create other helpful statistics.

Here are a few examples for value streams that can be easily and effectively
handled by time series.

- *A sequence of heart rate values can be collected from a smart
  wrist-watch*, and be used to build a person's training program.
- *Weather-stations' measurements* collected over a chosen time period
  can be compared to equivalent past periods to predict the weather.
- *Bandwidth usage reports of a home cable modem monitor* can be used
  to build a better charging plan.
- *Coordinates sent by delivery trucks' GPS trackers* can be collected
  and analyzed to secure the vehicles and improve the service.
- *Daily changes in stock prices* can be used to build investment plans.

#### RavenDB's Time Series Implementation

Time series functionality is fully integrated into RavenDB's
distributed environment and document model.

#### Distributed Time Series

Distributed clients and nodes can modify time series concurrently;  
the modifications are merged by the cluster [without conflict](https://docs.ravendb.net/7.2/document-extensions/timeseries/design.md#no-conflicts).

#### Time Series as Document Extensions

RavenDB's Time Series, like its
[distributed counters](https://docs.ravendb.net/7.2/document-extensions/counters/overview.md),
[attachments](https://docs.ravendb.net/7.2/document-extensions/attachments/overview.md)
and [document revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.md),
are **document extensions**.

- A time series always extends a single specific document.  
  The context and source of the time series can be kept clear this way,
  and time series management can use the comfort and strength of the
  document interface.  
  A barometer's specifications document, for example, can be the parent
  document for a time series that is populated with measurements taken
  by a barometer of this specification.

- Like the other document extensions, time series can take part in fully
  transactional operations.

#### Time Series Features

Notable time series features include -

- **Highly-Efficient Storage Management**  
  Time series data is [compressed](https://docs.ravendb.net/7.2/document-extensions/timeseries/design.md#compression)
  and [segmented](#time-series-segments) to minimize storage usage and transmission time.
- **A Thorough Set of API Methods**  
  The [time series API](https://docs.ravendb.net/7.2/document-extensions/timeseries/client-api/overview.md) includes a variety of `session methods` and `store operations`.
- **Full GUI Support**  
  Time series can be viewed and managed using [Studio](https://docs.ravendb.net/7.2/studio/database/document-extensions/time-series.md).
- **Time Series Indexing**  
  Time series can be [indexed](https://docs.ravendb.net/7.2/document-extensions/timeseries/indexing.md).
- **Time Series Querying and Aggregation**
  - [High-performance common queries](#common-queries-performance)  
    The results of a set of common queries are prepared in advance in time series segments' headers,  
    so the response to querying for a series minimum value, for example, is returned nearly instantly.
  - [LINQ and raw RQL queries](https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/overview-and-syntax.md)  
    Flexible queries and aggregations can be executed using LINQ expressions and raw RQL over  
    time series **timestamps**, **values**, and **tags**.
- **Including Time Series**  
  You can [include (pre-fetch) time series data](https://docs.ravendb.net/7.2/document-extensions/timeseries/client-api/session/include/overview.md) when loading or querying for documents.  
  Included data is held by the client's session, and is delivered to the user with no additional server calls.
- **Patching**  
  You can patch time series data into your documents.  
  Learn more in [Patching time series](https://docs.ravendb.net/7.2/document-extensions/timeseries/client-api/session/patch.md).
- **Rollup and Retention Policies**
  - [Rollup Policies](https://docs.ravendb.net/7.2/document-extensions/timeseries/rollup-and-retention.md)  
    You can set time series rollup policies to aggregate large series into smaller sets by your definitions.
  - [Retention Policies](https://docs.ravendb.net/7.2/document-extensions/timeseries/rollup-and-retention.md)  
    You can set time series retention policies to automatically remove time series entries that have reached their expiration date/time.

## Time Series Data

Time series **names** are kept in their parent documents' metadata, while their
**data** is kept [separately](#separate-name-and-data-storage).  
Time series data is **compressed** and composed of consecutive
[segments](#time-series-segments) and
[entries](#time-series-entries).

## Separate Name and Data Storage

The separation of names and data prevents time series value updates from
invoking document-change events, keeping documents' availability and performance
whatever size their time series grow to be and however frequent their value-updates
are.

## Time Series Segments

Time series are composed of consecutive **segments**.  
When a time series is created, its values are held in a single segment.  
As the number of values grows (or when a certain amount of time has passed
since the last entry appendage), segments are added to the series.

> **Info**
>
> Segments are managed automatically by RavenDB, clients do not need to do
> anything in this regard.

#### Transactions Performance

Time series segmentation heightens performance and minimizes transaction
and query time, since only the relevant segments of even a very long series
would be retrieved and queried, and only relevant segments would be updated.

#### Common Queries Performance

Segmentation also helps provide results for common queries extremely
fast, since results for such queries as `Min`, `Max` and others are
automatically stored and updated in segment headers, and are always
available for instant retrieval.

## Time Series Entries

Each time series segment is composed of consecutive **time series entries**.  
Each entry is composed of a **timestamp**, 1 to 32 **values**, and an **optional tag**.

#### Timestamps

> **Info**
>
> A single `DateTime` timestamp marks each entry in millisecond precision.

Timestamps are always indicated using [UTC](https://en.wikipedia.org/wiki/Coordinated_Universal_Time).

Timestamps, and therefore time series entries, are always ordered **by time**,
from the oldest timestamp to the newest.  
E.g. in a heart rate time series, timestamps would indicate the time in which each
heart rate measurement has been taken.

#### Values

> **Info**
>
> Up to 32 `double` **values** can be appended per-entry.

We allow storing as many as 32 values per entry, since appending multiple
values may be a requirement for some time series. Here are a few examples.

- A heart-rate time series  
  An entry with a single value (the heart-rate measurement taken by
  a smart wrist-watch) is added to the time series every minute.

- A truck-route time series  
  An entry with 2 values (the latitude and longitude reported by
  a GPS device) is added to the time series every minute.

- A stock-price time series  
  An entry with 5 values (stock price when the trade starts and
  ends, its highest and lowest prices during the day, and its daily
  trade volume) is added to the time series every day.

#### Tags

> **Info**
>
> A single **optional** `string` tag can be added per entry.

Tags are designated to provide information regarding their entries.

- **Descriptive Tags**  
  A tag can be a **short descriptive text**.

- **Reference Tags**  
  A tag can also contain a document's ID, and function as a **reference to this document**.

  A reference-tag is preferable when we want the tag to be very short and yet refer us
  to an unlimited source of information.

  Reference-tags can be used to [filter time series data](https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/filtering.md#using-tags-as-references---)
  during a query.  
  **E.g.**, the query can -  
  **1.** load time series entries whose tags refer to device-specification documents.  
  **2.** retrieve and examine the specification document referred to by each entry.  
  **3.** project to the client only values measured by Japanese devices.

  > **Info**
  >
  > Prefer re-using a few tags many times over using many unique tags,  
  > to minimize memory and storage usage and optimize time series performance.
