RavenDB 查询统计服务器执行时间(以毫秒为单位)
RavenDB Query Statistics server execution time in milliseconds
我正在尝试在执行给定查询时打印查询统计信息。我特别感兴趣的是服务器上的执行时间(以毫秒为单位)属性。下面是我的代码供参考
void Main()
{
var documentStore = DocumentStoreHolder.Store;
Load_Stats(documentStore);
}
// Define other methods and classes here
public static void Load_Stats(IDocumentStore documentStore)
{
using (var session = documentStore.OpenSession())
{
RavenQueryStatistics stats;
IRavenQueryable<Order> recentOrdersQuery = from order in session.Query<Order>().Statistics(out stats) where order.Company=="companies/1" select order;
List<Order> recentOrders = recentOrdersQuery.Take(3).ToList();
Console.WriteLine("Index used was: " + stats.IndexName);
Console.WriteLine($"Other stats : 1. Execution time on the server : {stats.DurationMilliseconds} 2.Total number of results {stats.TotalResults} 3. The last document ETag {stats.ResultEtag} 4. The timestamp of last document indexed by the index {stats.IndexTimestamp}");
}
但是在重复执行此查询后,我得到 运行 在服务器上查询所花费的时间(以毫秒为单位)为 -1。我不明白为什么会这样。我应该将结果分配给一个长变量还是允许打印结果(stats.DurationMilliseconds)。 TIA
最有可能的原因是,这是因为 RavenDB 能够处理来自客户端缓存的请求,而不是转到服务器
我正在尝试在执行给定查询时打印查询统计信息。我特别感兴趣的是服务器上的执行时间(以毫秒为单位)属性。下面是我的代码供参考
void Main()
{
var documentStore = DocumentStoreHolder.Store;
Load_Stats(documentStore);
}
// Define other methods and classes here
public static void Load_Stats(IDocumentStore documentStore)
{
using (var session = documentStore.OpenSession())
{
RavenQueryStatistics stats;
IRavenQueryable<Order> recentOrdersQuery = from order in session.Query<Order>().Statistics(out stats) where order.Company=="companies/1" select order;
List<Order> recentOrders = recentOrdersQuery.Take(3).ToList();
Console.WriteLine("Index used was: " + stats.IndexName);
Console.WriteLine($"Other stats : 1. Execution time on the server : {stats.DurationMilliseconds} 2.Total number of results {stats.TotalResults} 3. The last document ETag {stats.ResultEtag} 4. The timestamp of last document indexed by the index {stats.IndexTimestamp}");
}
但是在重复执行此查询后,我得到 运行 在服务器上查询所花费的时间(以毫秒为单位)为 -1。我不明白为什么会这样。我应该将结果分配给一个长变量还是允许打印结果(stats.DurationMilliseconds)。 TIA
最有可能的原因是,这是因为 RavenDB 能够处理来自客户端缓存的请求,而不是转到服务器