Article For
3.0 3.5 4.0 4.1 4.2 5.0 5.2 5.3

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;