---
title: "Stream Time Series Data"
description: "Stream large RavenDB time series query results to process entries one at a time without loading the entire result set into memory."
url: "https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/stream-timeseries"
version: "7.2"
language: "java"
---

# Stream Time Series Data

> Client language: Java. Also available for [C#](https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/stream-timeseries.md).
>
> 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."

> **Note**
>
> - This page explains how time series data can be streamed:
>   1. Stream a time series directly.
>   2. Stream time series query results.
>
> - In this page:
>   - [Syntax](#syntax)
>   - [Examples](#examples)

## Syntax

### Stream a time series directly:

Get a time series (using `timeSeriesFor().get()`, and call `stream()`).

```java
<T> CloseableIterator<StreamResult<T>> stream(IRawDocumentQuery<T> query);
```

| Parameters | Type | Description |
| - | - | - |
| **query** | `IRawDocumentQuery<T>` | Raw data |

### Stream results of time series queries:

This syntax is the same as the syntax for streaming query results in general,
found [here](https://docs.ravendb.net/7.2/querying/stream-query-results.java.md).

```java
<T> CloseableIterator<StreamResult<T>> stream(IDocumentQuery<T> query, Reference<StreamQueryStatistics> streamQueryStats);

<T> CloseableIterator<StreamResult<T>> stream(IRawDocumentQuery<T> query);

<T> CloseableIterator<StreamResult<T>> stream(IRawDocumentQuery<T> query, Reference<StreamQueryStatistics> streamQueryStats);
```

| Parameters | | |
| - | - | - |
| **query** | [IDocumentQuery](https://docs.ravendb.net/7.2/querying/overview.md#sessionadvanceddocumentquery) or [IRawDocumentQuery](https://docs.ravendb.net/7.2/querying/overview.md#sessionadvancedrawquery) | Query to stream results for. |
| `Reference` **streamQueryStats** | StreamQueryStatistics | Information about performed query. |

| Return Value | |
| - | - |
| CloseableIterator\<StreamResult> | Iterator with entities. |

## Examples

[comment]: https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/%3C

### Example I

Using `timeSeriesFor`:

```java
ISessionDocumentTimeSeries timeseries = session.timeSeriesFor("HeartRate", "user/1-A");
```

\> (There isn't get to stream, a sample couldn't exists like that)

### Example

Using a `rawQuery`:

```java
IRawDocumentQuery<Employee> query = session.advanced()
  .rawQuery(Employee.class,
      "from Users\n" +
      "select timeseries (\n" +
      "    from HeartRate\n"+
      ")"
  );

CloseableIterator<StreamResult<Employee>> results = session.advanced().stream(query);
```

## See also

- [Time Series Overview](https://docs.ravendb.net/7.2/document-extensions/timeseries/overview.md)
- [Range Selection](https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/choosing-query-range.md)
- [Filtering](https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/filtering.md)
- [Aggregation and Projection](https://docs.ravendb.net/7.2/document-extensions/timeseries/querying/aggregation-and-projections.md)
- [Get Time Series Entries](https://docs.ravendb.net/7.2/document-extensions/timeseries/client-api/session/get/get-entries.md)
- [How To Stream Query Results](https://docs.ravendb.net/7.2/querying/stream-query-results.java.md)
