Skip to content

Commit

Permalink
Merge pull request #1740 from Danielle9897/RDoc-2337-streamingQuery
Browse files Browse the repository at this point in the history
RDoc-2337  Streaming query with WaitForNonStaleResults is not supported
  • Loading branch information
ppekrol authored Feb 1, 2024
2 parents 572bca0 + a78bfc0 commit b6543e0
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,45 +1,60 @@
# Stream Query Results

---

{NOTE: }

* RavenDB supports __streaming data__ from the server to the client.
Streaming is useful when processing a large number of results.

* The data streamed can be a result of a dynamic query, a static index query,
or just filtered by a prefix.

* Neither the client nor the server holds the full response in memory.
Instead, as soon as the server has a __single result__, it sends it to the client,
Thus, your application can start processing results before the server sends them all.

* The stream results are __not tracked__ by the session.
Changes made to them will not be sent to the server when _SaveChanges_ is called.

* The stream results are a __snapshot of the data__ at the time when the query is computed by the server.
Results that match the query after it was already processed are not streamed to the client.

* Streaming query results does not support using [include](../../../client-api/session/loading-entities#load-with-includes).
Learn how to __stream related documents__ here [below](../../../client-api/session/querying/how-to-stream-query-results#stream-related-documents).
* The data streamed can be a result of a dynamic query, a static index query, or just filtered by a prefix.

* To stream results, use the `Stream` method from the `Advanced` session operations.

* In this page:

* [Streaming overview](../../../client-api/session/querying/how-to-stream-query-results#streaming-overview)

* [Stream by query](../../../client-api/session/querying/how-to-stream-query-results#stream-by-query)
* [Stream a dynamic query](../../../client-api/session/querying/how-to-stream-query-results#stream-a-dynamic-query)
* [Stream a dynamic raw query](../../../client-api/session/querying/how-to-stream-query-results#stream-a-dynamic-raw-query)
* [Stream a projected query](../../../client-api/session/querying/how-to-stream-query-results#stream-a-projected-query)
* [Stream an index query](../../../client-api/session/querying/how-to-stream-query-results#stream-an-index-query)
* [Stream related documents](../../../client-api/session/querying/how-to-stream-query-results#stream-related-documents)
* [By query syntax](../../../client-api/session/querying/how-to-stream-query-results#by-query-syntax)

* [Stream by prefix](../../../client-api/session/querying/how-to-stream-query-results#stream-by-prefix)
* [Stream results by prefix](../../../client-api/session/querying/how-to-stream-query-results#stream-results-by-prefix)
* [By prefix syntax](../../../client-api/session/querying/how-to-stream-query-results#by-prefix-syntax)

{NOTE/}

---

{PANEL: Streaming overview}

* __Immediate processing__:
Neither the client nor the server holds the full response in memory.
Instead, as soon as the server has a single result, it sends it to the client.
Thus, your application can start processing results before the server sends them all.

* __No tracking__:
The stream results are Not tracked by the session.
Changes made to the resulting entities will not be sent to the server when _SaveChanges_ is called.

* __A snapshot of the data__:
The stream results are a snapshot of the data at the time when the query is computed by the server.
Results that match the query after it was already processed are Not streamed to the client.

* __Query limitations:__:

* A streaming query does not wait for indexing by design.
So calling [WaitForNonStaleResults](../../../client-api/session/querying/how-to-customize-query#waitfornonstaleresults) is Not supported and will result in an exception.

* Using [Include](../../../client-api/how-to/handle-document-relationships#includes) to load a related document to the session in a streaming query is Not supported.
Learn how to __stream related documents__ here [below](../../../client-api/session/querying/how-to-stream-query-results#stream-related-documents).

{PANEL/}

{PANEL: Stream by query}

{NOTE: }
Expand Down Expand Up @@ -94,7 +109,7 @@
__Why streaming query results does not support 'include'__:

* A document can reference [related documents](../../../indexes/indexing-related-documents#what-are-related-documents).
* An [include](../../../client-api/session/loading-entities#load-with-includes) clause in a non-streamed query loads these related documents to the session
* An [Include](../../../client-api/how-to/handle-document-relationships#includes) clause in a non-streamed query loads these related documents to the session
so that they can be accessed without an additional query to the server.
* Those included documents are sent to the client at the end of the query results.
This does not mesh well with streaming, which is designed to allow transferring massive amounts of data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# Stream Query Results

Query results can be streamed using the `stream` method from the `advanced` session operations. The query can be issued using either a static index, or it can be a dynamic one where it will be handled by an auto index.
RavenDB supports __streaming data__ from the server to the client.
Streaming is useful when processing a large number of results.

The data streamed can be a result of a dynamic query, a static index query, or just filtered by a prefix.

To stream results, use the `stream` method from the `advanced` session operations.

---

{PANEL: Streaming overview}

* __Immediate processing__:
Neither the client nor the server holds the full response in memory.
Instead, as soon as the server has a single result, it sends it to the client.
Thus, your application can start processing results before the server sends them all.

* __No tracking__:
The stream results are Not tracked by the session.
Changes made to the resulting entities will not be sent to the server when _saveChanges_ is called.

* __A snapshot of the data__:
The stream results are a snapshot of the data at the time when the query is computed by the server.
Results that match the query after it was already processed are Not streamed to the client.

* __Query limitations:__:

* A streaming query does not wait for indexing by design.
So calling [waitForNonStaleResults](../../../client-api/session/querying/how-to-customize-query#waitfornonstaleresults) is Not supported and will result in an exception.

* Using [include](../../../client-api/session/loading-entities#load-with-includes) to load a related document to the session in a streaming query is Not supported.

{PANEL/}

## Syntax

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,22 @@
* RavenDB supports __streaming data__ from the server to the client.
Streaming is useful when processing a large number of results.

* The data streamed can be a result of a dynamic query, a static index query,
or just filtered by a prefix.

* Neither the client nor the server holds the full response in memory.
Instead, as soon as the server has a __single result__, it sends it to the client,
Thus, your application can start processing results before the server sends them all.

* The stream results are __not tracked__ by the session.
Changes made to them will not be sent to the server when _saveChanges_ is called.

* The stream results are a __snapshot of the data__ at the time when the query is computed by the server.
Results that match the query after it was already processed are not streamed to the client.

* Streaming query results does not support using [include](../../../client-api/session/loading-entities#load-with-includes).
Learn how to __stream related documents__ here [below](../../../client-api/session/querying/how-to-stream-query-results#stream-related-documents).
* The data streamed can be a result of a dynamic query, a static index query, or just filtered by a prefix.

* To stream results, use the `stream` method from the `advanced` session operations.

* In this page:

* [Streaming overview](../../../client-api/session/querying/how-to-stream-query-results#streaming-overview)

* [Stream by query](../../../client-api/session/querying/how-to-stream-query-results#stream-by-query)
* [Stream a dynamic query](../../../client-api/session/querying/how-to-stream-query-results#stream-a-dynamic-query)
* [Stream a dynamic raw query](../../../client-api/session/querying/how-to-stream-query-results#stream-a-dynamic-raw-query)
* [Stream a projected query](../../../client-api/session/querying/how-to-stream-query-results#stream-a-projected-query)
* [Stream an index query](../../../client-api/session/querying/how-to-stream-query-results#stream-an-index-query)
* [Stream related documents](../../../client-api/session/querying/how-to-stream-query-results#stream-related-documents)
* [By query syntax](../../../client-api/session/querying/how-to-stream-query-results#by-query-syntax)

* [Stream by prefix](../../../client-api/session/querying/how-to-stream-query-results#stream-by-prefix)
* [Stream results by prefix](../../../client-api/session/querying/how-to-stream-query-results#stream-results-by-prefix)
* [By prefix syntax](../../../client-api/session/querying/how-to-stream-query-results#by-prefix-syntax)
Expand All @@ -41,6 +31,31 @@

---

{PANEL: Streaming overview}

* __Immediate processing__:
Neither the client nor the server holds the full response in memory.
Instead, as soon as the server has a single result, it sends it to the client.
Thus, your application can start processing results before the server sends them all.

* __No tracking__:
The stream results are Not tracked by the session.
Changes made to the resulting entities will not be sent to the server when _saveChanges_ is called.

* __A snapshot of the data__:
The stream results are a snapshot of the data at the time when the query is computed by the server.
Results that match the query after it was already processed are Not streamed to the client.

* __Query limitations:__:

* A streaming query does not wait for indexing by design.
So calling [waitForNonStaleResults](../../../client-api/session/querying/how-to-customize-query#waitfornonstaleresults) is Not supported and will result in an exception.

* Using [include](../../../client-api/session/loading-entities#load-with-includes) to load a related document to the session in a streaming query is Not supported.
Learn how to __stream related documents__ here [below](../../../client-api/session/querying/how-to-stream-query-results#stream-related-documents).

{PANEL/}

{PANEL: Stream by query}

{NOTE: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ __Syntax__

* A `TimeoutException` will be thrown if the query is not able to return non-stale results within the specified
(or default) timeout.

* Note: This feature is Not available when [streaming the query results](../../../client-api/session/querying/how-to-stream-query-results).
Calling _WaitForNonStaleResults_ with a streaming query will throw an exception.

* Learn more about stale results in [stale indexes](../../../indexes/stale-indexes).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ To order results randomly, use the `randomOrdering` method.
Queries can be 'instructed' to wait for non-stale results for a specified amount of time using the `waitForNonStaleResults` method. If the query won't be able to return
non-stale results within the specified (or default) timeout, then a `TimeoutException` is thrown.

Note: This feature is Not available when [streaming the query results](../../../client-api/session/querying/how-to-stream-query-results).
Calling _waitForNonStaleResults_ with a streaming query will throw an exception.

{NOTE: Cutoff Point}
If a query sent to the server specifies that it needs to wait for non-stale results, then RavenDB sets the cutoff Etag for the staleness check.
It is the Etag of the last document (or document tombstone), from the collection(s) processed by the index, as of the query arrived to the server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ __Syntax__
* A `TimeoutException` will be thrown if the query is not able to return non-stale results within the specified
(or default) timeout.

* Note: This feature is Not available when [streaming the query results](../../../client-api/session/querying/how-to-stream-query-results).
Calling _waitForNonStaleResults_ with a streaming query will throw an exception.

* Learn more about stale results in [stale indexes](../../../indexes/stale-indexes).

{NOTE: }
Expand Down

0 comments on commit b6543e0

Please sign in to comment.