Skip to content

Commit

Permalink
RDoc-2475 Client API > Session > Querying > Count query results - Part 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielle9897 committed Jul 31, 2023
1 parent bc5428f commit e90000d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ from "Employees" where FirstName == "Anne"
| **DurationInMs** | `long` | Query duration on the server side in Milliseconds |
| **TotalResults** | `int` | The total count of results that matched the query as `Int32`.<br>Matching query results can also be counted as `Int32` using [Count](../../../client-api/session/querying/how-to-count-query-results#count). |
| **LongTotalResults** | `long` | The total count of the results that matched the query as `Int64`.<br>Matching query results can also be counted as `Int64` using [LongCount](../../../client-api/session/querying/how-to-count-query-results#longcount). |
| **SkippedResults** | `int` | Gets or sets the [skipped results](../../../indexes/querying/paging#paging-through-tampered-results) |
| **SkippedResults** | `int` | The number of results skipped by the server.<br>Learn more in [paging through tampered results](../../../indexes/querying/paging#paging-through-tampered-results). |
| **Timestamp** | `DateTime` | The time when the query results were unstale |
| **IndexName** | `string` | The name of the queried index |
| **DateTime** | `IndexTimestamp` | The timestamp of the queried index |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Session: Querying: How to Get Query Statistics
# Get Query Statistics

Query statistics can provide important information about a query like duration, total number of results, staleness information, etc. To access statistics use the `statistics` method.
Query statistics can provide important information about a query like duration, total number of results, staleness information, etc.
To access statistics use the `statistics` method.

## Example

{CODE:java stats_3@ClientApi\Session\Querying\HowToGetQueryStatistics.java /}

## Syntax

Expand All @@ -10,10 +15,23 @@ Query statistics can provide important information about a query like duration,
| ------------- | ------------- | ----- |
| **stats** | `QueryStatistics` | Statistics for query. |

## Example

{CODE:java stats_2@ClientApi\Session\Querying\HowToGetQueryStatistics.java /}


| Property | Type | Description |
|----------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **IsStale** | `boolean` | Are the results returned by the query potentially stale |
| **DurationInMs** | `long` | Query duration on the server side in Milliseconds |
| **TotalResults** | `int` | The total count of results that matched the query as `int` |
| **LongTotalResults** | `long` | The total count of the results that matched the query as `long` |
| **SkippedResults** | `int` | The number of results skipped by the server.<br>Learn more in [paging through tampered results](../../../indexes/querying/paging#paging-through-tampered-results). |
| **Timestamp** | `Date` | The time when the query results were unstale |
| **IndexName** | `string` | The name of the queried index |
| **indexTimestamp** | `Date` | The timestamp of the queried index |
| **LastQueryTime** | `Date` | The timestamp of the last time the index was queried |
| **ResultEtag** | `Long` | Results Etag |
| **NodeTag** | `String` | Tag of the cluster node that responded to the query |

## Related articles

### Session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ from "Employees" where FirstName == "Anne"
|-------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| __statsCallback__ | `(stats) => void` | <ul><li>A callback function with an output parameter.</li><li>The parameter passed to the callback will be filled with the `QueryStatistics` object when query returns.</li></ul> |

| `QueryStatistics` | | |
|----------------------|-----------|----------------------------------------------------------------------------|
| __isStale__ | `boolean` | Are the results returned by the query potentially stale |
| __durationInMs__ | `number` | Query duration on the server side in Milliseconds |
| __totalResults__ | `number` | The total count of results that matched the query |
| __longTotalResults__ | `number` | The total count of results that matched the query (same as `totalResults`) |
| __skippedResults__ | `number` | Dictionary with `QueryTimings` info per time part |
| __timestamp__ | `Date` | The time when the query results were unstale |
| __indexName__ | `string` | The name of the queried index |
| __indexTimestamp__ | `Date` | The timestamp of the queried index |
| __lastQueryTime__ | `Date` | The timestamp of the last time the index was queried |
| __resultEtag__ | `number` | Results Etag |
| __nodeTag__ | `string` | Tag of the cluster node that responded to the query |
| `QueryStatistics` | | |
|----------------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| __isStale__ | `boolean` | Are the results returned by the query potentially stale |
| __durationInMs__ | `number` | Query duration on the server side in Milliseconds |
| __totalResults__ | `number` | The total count of results that matched the query |
| __longTotalResults__ | `number` | The total count of results that matched the query (same as `totalResults`) |
| __skippedResults__ | `number` | The number of results skipped by the server.<br>Learn more in [paging through tampered results](../../../indexes/querying/paging#paging-through-tampered-results). |
| __timestamp__ | `Date` | The time when the query results were unstale |
| __indexName__ | `string` | The name of the queried index |
| __indexTimestamp__ | `Date` | The timestamp of the queried index |
| __lastQueryTime__ | `Date` | The timestamp of the last time the index was queried |
| __resultEtag__ | `number` | Results Etag |
| __nodeTag__ | `string` | Tag of the cluster node that responded to the query |

{PANEL/}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,31 @@ private interface IFoo<T> {
IDocumentQuery<T> statistics(Reference<QueryStatistics> stats);
//endregion
}

private interface Foo<T> {
//region stats_2
public class QueryStatistics {

private boolean isStale;
private long durationInMs;
private int totalResults;
private long longTotalResults;
private int skippedResults;
private Date timestamp;
private String indexName;
private Date indexTimestamp;
private Date lastQueryTime;
private Long resultEtag;
private String nodeTag;

}
//endregion
}

public HowToGetQueryStatistics() {
try (IDocumentStore store = new DocumentStore()) {
try (IDocumentSession session = store.openSession()) {
//region stats_2
//region stats_3
Reference<QueryStatistics> stats = new Reference<>();

List<Employee> employees = session.query(Employee.class)
Expand Down

0 comments on commit e90000d

Please sign in to comment.