You are currently browsing legacy 3.5 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 query e.g. duration, total number of results, staleness information, etc. To access statistics use statistics method.


IRavenQueryable<TResult> statistics(Reference<RavenQueryStatistics> stats);
stats RavenQueryStatistics Statistics for query.
Return Value
RavenQueryStatistics Statistics for query.


Reference<RavenQueryStatistics> statsRef = new Reference<>();
QEmployee e = QEmployee.employee;
List<Employee> employees = session

int totalResults = statsRef.value.getTotalResults();
long durationMiliseconds = statsRef.value.getDurationMiliseconds();