You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Querying: How to get query statistics?

Query statistics can provide important information about query e.g. duration, total number of results, staleness information, etc. To access statistics use Statistics method.

Syntax

IRavenQueryable<TResult> Statistics(out RavenQueryStatistics stats);

Parameters
stats RavenQueryStatistics Statistics for query.
Return Value
RavenQueryStatistics Statistics for query.

Example

RavenQueryStatistics stats;
List<Employee> employees = session.Query<Employee>()
	.Where(x => x.FirstName == "Robert")
	.Statistics(out stats)
	.ToList();

int totalResults = stats.TotalResults;
long durationMilliseconds = stats.DurationMilliseconds;