Proper Way to Retrieve More than 128 Documents with RavenDB

前端 未结 5 1866
执念已碎
执念已碎 2020-12-13 01:07

I know variants of this question have been asked before (even by me), but I still don\'t understand a thing or two about this...

It was my understanding that one cou

5条回答
  •  离开以前
    2020-12-13 01:35

    Number of request per session is a separate concept then number of documents retrieved per call. Sessions are short lived and are expected to have few calls issued over them.

    If you are getting more then 10 of anything from the store (even less then default 128) for human consumption then something is wrong or your problem is requiring different thinking then truck load of documents coming from the data store.

    RavenDB indexing is quite sophisticated. Good article about indexing here and facets here.

    If you have need to perform data aggregation, create map/reduce index which results in aggregated data e.g.:

    Index:

        from post in docs.Posts
        select new { post.Author, Count = 1 }
    
        from result in results
        group result by result.Author into g
        select new
        {
           Author = g.Key,
           Count = g.Sum(x=>x.Count)
        }
    

    Query:

    session.Query("Posts/ByUser/Count")(x=>x.Author)();
    

提交回复
热议问题