Include Query Timings
-
When making a query,
you can request to get detailed stats of the time spent by RavenDB on each part of the query.
E.g. duration of search, loading documents, transforming results, total duration, etc. -
By default, the timings stats are Not included in the query results, to avoid the measuring overhead.
-
To include the query timings in the query results:
add a call totimings()
in your query code, or addinclude timings()
to an RQL query.
See examples below. -
In this page:
Include timings in a query
Reference<QueryTimings> timingsRef = new Reference<>();
List<Product> resultsWithTimings = session.advanced().documentQuery(Product.class)
.timings(timingsRef)
.search("Name", "Syrup")
.toList();
Map<String, QueryTimings> timingsMap = timingsRef.value.getTimings();
from "Products"
where search(Name, "Syrup") or search(Name, "Lager")
include timings()
View timings
-
The detailed timings can be viewed from the Query view in the Studio.
-
Running an RQL query with
include timings()
will show an additional Timings Tab
with a graphical representation of the time spent in each query part.
Include timings results
Syntax
IDocumentQueryCustomization timings(Reference<QueryTimings> timings);
The QueryTimings
object will be filled with the timings when the query returns.
QueryTimings |
||
---|---|---|
durationInMs | long |
Total duration |
timings | Map<String, QueryTimings> |
Dictionary with QueryTimings info per time part |
Timings in a sharded database
-
In a sharded database, timings for each part are provided per shard.
-
Learn more in timings in a sharded database.