RavenDB查询统计服务器执行时间(毫秒)

RavenDB查询统计服务器执行时间(毫秒),ravendb,long-integer,milliseconds,Ravendb,Long Integer,Milliseconds,我试图在执行给定查询时打印查询统计信息。我特别感兴趣的是服务器上以毫秒为单位的执行时间属性。下面是我的代码供参考 void Main() { var documentStore = DocumentStoreHolder.Store; Load_Stats(documentStore); } // Define other methods and classes here public static void Load_Stats(IDocumentStore documen

我试图在执行给定查询时打印查询统计信息。我特别感兴趣的是服务器上以毫秒为单位的执行时间属性。下面是我的代码供参考

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}");
}
void Main()
{
var documentStore=DocumentStoreHolder.Store;
加载统计数据(文档存储);
}
//在此处定义其他方法和类
公共静态无效负载统计(IDocumentStore documentStore)
{
使用(var session=documentStore.OpenSession())
{
拉文奎尔统计数据;
IRavenQueryable recentOrdersQuery=来自session.Query()中的订单。统计信息(out stats),其中order.Company==“companys/1”选择订单;
List recentOrders=recentOrdersQuery.Take(3.ToList();
WriteLine(“使用的索引为:+stats.IndexName”);
Console.WriteLine($“其他统计信息:1.服务器上的执行时间:{stats.DurationMillimes}2.结果总数{stats.TotalResults}3.最后一个文档ETag{stats.ResultEtag}4.索引{stats.IndexTimestamp}索引的最后一个文档的时间戳”);
}

但在重复执行此查询时,我在服务器上运行查询所花费的时间(以毫秒为单位)为-1。我无法理解为什么会发生这种情况。我应该将结果分配给一个长变量,还是允许打印结果(stats.durationmillizes).TIA

最可能的原因是,这是因为RavenDB能够从客户端缓存提供请求,而不是转到服务器

谢谢Oren!我尝试了一个不同的谓词,我在以前的查询中没有使用过,我能够得到一个有效的结果。我将探索客户端中的选项以禁用缓存进行测试。