You are currently browsing legacy 5.0 version of documentation. Click here to switch to the newest 5.1 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 a query like duration, total number of results, staleness information, etc. To access statistics use the Statistics method.


IRavenQueryable<TResult> Statistics(out QueryStatistics stats);
stats QueryStatistics Statistics for query.


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

int totalResults = stats.TotalResults;
long durationInMilliseconds = stats.DurationInMs;