2017-04-24 12 views
0

주어진 쿼리 실행시 쿼리 통계를 인쇄하려고합니다. 특히 밀리 초 속성의 서버에서 실행 시간에 관심이 있습니다. 아래 코드는 참조 용입니다.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이됩니다. 나는 왜 그런 일이 일어나고 있는지 이해하지 못하고있다. 결과를 long 변수에 지정해야합니까? 그렇지 않으면 결과를 인쇄 할 수 있습니까 (stats.DurationMilliseconds). TIA

답변

1

가장 큰 이유는 RavenDB가 서버로 이동하는 대신 클라이언트 캐시에서 요청을 처리 할 수 ​​있기 때문입니다.

+0

감사합니다. 나는 이전 쿼리에서 사용하지 않은 다른 술어를 시도했는데 유효한 결과를 얻을 수있었습니다. 테스트를 위해 캐시를 사용하지 않도록 클라이언트 쪽에서 옵션을 탐색합니다. –