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.
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
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
Time Series Features
Notable time series features include -
Highly-Efficient Storage Management
Time series data is compressed
to minimize storage usage and transmission time.
A Thorough Set of API Methods
The time series API**
includes a variety of session methods and store operations.
Full GUI Support
Time series can be viewed and managed using the Studio.
Time Series Querying and Aggregation
High-performance common queries
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
Flexible queries and aggregations can be executed using LINQ expressions and raw RQL
over time series timestamps, tags and values.
You can set time series rollup policies to aggregate large series into
smaller sets by your definitions.
You can set time series retention policies to automatically remove
time series entries that have reached their expiration date/time.
Including Time Series
You can include (pre-fetch) time series data while loading documents.
Included data is held by the client's session, and is delivered to the
user with no additional server calls.
You can patch time series data to your documents.
(visit the API documentation to learn more).
Time Series Data
Time series names are kept in their parent documents' metadata, while their
data is kept separately.
Time series data is compressed and composed of consecutive
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
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.
Segments are managed automatically by RavenDB, clients do not need to do
anything in this regard.
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.
A single DateTime timestamp marks each entry in millisecond precision.
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.
Up to 32 doublevalues 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.
A single optionalstring tag can be added per entry.
Tags are designated to provide information regarding their entries.
A tag can be a short descriptive text.
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
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.
Prefer re-using a few tags many times over using many unique tags,
to minimize memory and storage usage and optimize time series performance.